This buglet causes a crash on wxStyledTextCtrl.AddRefDocument
is invoked.
Short form: wxPython/contrib/stc/contrib/src/stc/stc.cpp needs to be
patched in AddRefDocument and ReleaseDocument so that the
correct parameter is passed. The params should be
(msg,0,docpointer) but currently they are (msg,docpointer).
Wordy version:
I am trying to use SetDocPointer/GetDocPointer/AddRefDocument
and I found that my app crashed when AddRefDocument was called
from a Python statement such as
self.dp = self.edit.GetDocPointer()
self.edit.AddRefDocument(self.dp)
Having a source distro set up with MS VC++, started Python and my app
thru VC++ and let the crash show me where the error was.
It's in contrib/stc/contrib/src/stc/scintilla/src/Document.cxx:
// Increase reference count and return its previous value.
int Document::AddRef() {
return refCount++;
}
but the 'this' at that point was 0, so of course it crashed.
ANYWAY, to make a long story short, I traced back up
thru the stack-context and saw that what was happening is
that the lparam input to the WndProc seems to be zero
and that the wparam, which should be zero is the doc
pointer.
This affects stc.cpp:
···
------------------------------------------------------------------------------
// Extend life of document.
void wxStyledTextCtrl::AddRefDocument(void* docPointer) {
SendMsg(2376, (long)docPointer);
}
// Release a reference to the document, deleting document if it fades to black.
void wxStyledTextCtrl::ReleaseDocument(void* docPointer) {
SendMsg(2377, (long)docPointer);
-------------------------------------------------------------------------------
In BOTH these cases, the SendMsg should look like
SendMsg(###,0,(long)docPointer)
as is done correctly in SetDocPointer:
// Change the document object used.
void wxStyledTextCtrl::SetDocPointer(void* docPointer) {
SendMsg(2358, 0, (long)docPointer);
}
This way wparam is 0 and lparam is the docPointer.
I am using a source tree downloaded from CVS several weeks ago,
and looking at it right now via ViewCVS this buglet is still present.
I patched the src and the prob went away, altho I am not using
ReleaseDocument() so could not test it.
I also posted this to the SourceForge wxWindows tracker, but
it disappeared... Hmm.
Regards,
Jeff Sasmor
#--------------------------------
Jeff Sasmor
jeff@sasmor.com