Developer forums (C::B DEVELOPMENT STRICTLY!) > CodeCompletion redesign

annoying crash when debugging CC's auto-suggestion

(1/4) > >>

ollydbg:
Debug C::B under C::B using gdb, then set a bp in the function: int CodeCompletion::CodeComplete() (around line 2061 of codecompletion.cpp), then run several steps (or step int some functions like MarkItemsByAI()), then continue running will cause the debugee C::B crash in the line

--- Code: --- ed->GetControl()->AutoCompShow(pos - start, final);
--- End code ---

I debugged some time, and find that the above line try to pop-up the autocompletion window. But when the debugee C::B stops at a bp which is before call the function AutoCompShow(), there will be a window switch. I mean, the debugee C::B will receive a KillFocus event.

What I see the crash backtrace is:

--- Code: ---[debug]#0  0x61a08afa in wxSCIListBoxWin::GetLB (this=0x0) at E:\code\cb\cleantrunk\src\sdk\wxscintilla\src\PlatWX.cpp:1043
[debug]#1  0x619eb809 in GETLB (win=0x0) at E:\code\cb\cleantrunk\src\sdk\wxscintilla\src\PlatWX.cpp:1218
[debug]#2  0x618e2f70 in ListBoxImpl::Length (this=0x3dbf1d8) at E:\code\cb\cleantrunk\src\sdk\wxscintilla\src\PlatWX.cpp:1414
[debug]#3  0x6198e9e8 in AutoComplete::Select (this=0x1c20fb0, word=0x3ea8d84 "ac") at E:\code\cb\cleantrunk\src\sdk\wxscintilla\src\scintilla\src\AutoComplete.cxx:148
[debug]#4  0x61978e76 in ScintillaBase::AutoCompleteMoveToCurrentWord (this=0x1c205c0) at E:\code\cb\cleantrunk\src\sdk\wxscintilla\src\scintilla\src\ScintillaBase.cxx:300
[debug]#5  0x61978d14 in ScintillaBase::AutoCompleteStart (this=0x1c205c0, lenEntered=2, list=0x3ddd290 "accB?1\naccess(): int __cdecl?13\naccumulate?40\nacos(): double __cdecl?13\nacosf(): float __cdecl?13\nacosh(): double __cdecl?13\nacoshf(): float __cdecl?13\nacoshl(): long double __cdecl?13\nacosl(): long d"...) at E:\code\cb\cleantrunk\src\sdk\wxscintilla\src\scintilla\src\ScintillaBase.cxx:277
[debug]#6  0x6197a491 in ScintillaBase::WndProc (this=0x1c205c0, iMessage=2100, wParam=2, lParam=64869008) at E:\code\cb\cleantrunk\src\sdk\wxscintilla\src\scintilla\src\ScintillaBase.cxx:666
[debug]#7  0x618def3f in ScintillaWX::WndProc (this=0x1c205c0, iMessage=2100, wParam=2, lParam=64869008) at E:\code\cb\cleantrunk\src\sdk\wxscintilla\src\ScintillaWX.cpp:883
[debug]#8  0x618d02b9 in wxScintilla::SendMsg (this=0x3d9ef40, msg=2100, wp=2, lp=64869008) at E:\code\cb\cleantrunk\src\sdk\wxscintilla\src\wxscintilla.cpp:270
[debug]#9  0x618d21e3 in wxScintilla::AutoCompShow (this=0x3d9ef40, lenEntered=2, itemList="accB?1\naccess(): int __cdecl?13\naccumulate?40\nacos(): double __cdecl?13\nacosf(): float __cdecl?13\nacosh(): double __cdecl?13\nacoshf(): float __cdecl?13\nacoshl(): long double __cdecl?13\nacosl(): long d"...) at E:\code\cb\cleantrunk\src\sdk\wxscintilla\src\wxscintilla.cpp:1203
[debug]#10 0x65e8d7a7 in CodeCompletion::CodeComplete (this=0x39c6180) at E:\code\cb\cleantrunk\src\plugins\codecompletion\codecompletion.cpp:2240
[debug]#11 0x65e976b3 in CodeCompletion::DoCodeComplete (this=0x39c6180) at E:\code\cb\cleantrunk\src\plugins\codecompletion\codecompletion.cpp:4127
[debug]#12 0x65e910d5 in CodeCompletion::EditorEventHook (this=0x39c6180, editor=0x3c8f0a8, event=...) at E:\code\cb\cleantrunk\src\plugins\codecompletion\codecompletion.cpp:2947
[debug]#13 0x65f29c7d in EditorHooks::HookFunctor<CodeCompletion>::Call (this=0x3bf1540, editor=0x3c8f0a8, event=...) at E:\code\cb\cleantrunk\src\include\editor_hooks.h:49
[debug]#14 0x6189a021 in EditorHooks::CallHooks (editor=0x3c8f0a8, event=...) at E:\code\cb\cleantrunk\src\sdk\editor_hooks.cpp:69
[debug]#15 0x6183b03d in cbEditor::OnScintillaEvent (this=0x3c8f0a8, event=...) at E:\code\cb\cleantrunk\src\sdk\cbeditor.cpp:3280
[debug]#16 0x6183a335 in cbEditor::OnEditorCharAdded (this=0x3c8f0a8, event=...) at E:\code\cb\cleantrunk\src\sdk\cbeditor.cpp:3037
[debug]#17 0x00e7ff27 in wxEvtHandler::ProcessEventIfMatches(wxEventTableEntryBase const&, wxEvtHandler*, wxEvent&) () from E:\code\cb\cleantrunk\src\devel\wxmsw28u_gcc_custom.dll

--- End code ---

It crash at the function:

--- Code: ---inline wxSCIListBoxWin* GETLBW(WindowID win) {
    return ((wxSCIListBoxWin*)win);
}

inline wxListView* GETLB(WindowID win) {
    return GETLBW(win)->GetLB();
}

.....
int ListBoxImpl::Length()
{
    return GETLB(wid)->GetItemCount();
}

--- End code ---
But the "wid" is currently 0. I found the reason is, when a KillFocus is received, it will finally let the auto-completion canceled. So


--- Code: ---void Window::Destroy()
{
    if (wid) {
        Show(false);
        GETWIN(wid)->Destroy();
    }
    wid = 0;
}

--- End code ---
will be called.

The interesting thing is: If you set two bps in the switch statement below(one for each case), you will see firstly it entered a SCI_AUTOCSHOW, and later a SCI_AUTOCCANCEL.


--- Code: ---sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
switch (iMessage) {
case SCI_AUTOCSHOW:
listType = 0;
AutoCompleteStart(wParam, reinterpret_cast<const char *>(lParam));
break;

case SCI_AUTOCCANCEL:
ac.Cancel();
break;

--- End code ---

My question is: how to solve this issue? Thanks.

(Another question is: how to build C::B which can link to a debug version of wxWidgets library, so that I can see/track the messages more clearly, currently, gdb's bt command always stop at [debug]#17 0x00e7ff27 in wxEvtHandler::ProcessEventIfMatches(wxEventTableEntryBase const&, wxEvtHandler*, wxEvent&) () from E:\code\cb\cleantrunk\src\devel\wxmsw28u_gcc_custom.dll)



oBFusCATed:

--- Quote from: ollydbg on December 31, 2012, 10:21:54 am ---My question is: how to solve this issue? Thanks.

--- End quote ---
I don't know, you're the cc master here.


--- Quote from: ollydbg on December 31, 2012, 10:21:54 am ---(Another question is: how to build C::B which can link to a debug version of wxWidgets library, so that I can see/track the messages more clearly, currently, gdb's bt command always stop at [debug]#17 0x00e7ff27 in wxEvtHandler::ProcessEventIfMatches(wxEventTableEntryBase const&, wxEvtHandler*, wxEvent&) () from E:\code\cb\cleantrunk\src\devel\wxmsw28u_gcc_custom.dll)

--- End quote ---
Build options->Custom variables and probably you should define some wxdebug macros...

Jenna:

--- Quote from: ollydbg on December 31, 2012, 10:21:54 am ---My question is: how to solve this issue? Thanks.

--- End quote ---
If it's a misuse on our side, fix it here, if it is an issue in the wxScintilla-code (it's based on wxSTC) it can be fixed there and a bug-report filed against wxWidgets bug-tracker, if it is a problem with Scintilla itself, it should be fixed there and a bug-report shoukld be filed against Scintilla.

p2rkw:
@ollydbg:
Can you test this patch?
--- Code: ---Index: src/sdk/wxscintilla/src/PlatWX.cpp
===================================================================
--- src/sdk/wxscintilla/src/PlatWX.cpp (wersja 8739)
+++ src/sdk/wxscintilla/src/PlatWX.cpp (kopia robocza)
@@ -1286,7 +1286,21 @@
     lineHeight =  lineHeight_;
     unicodeMode = unicodeMode_;
     maxStrWidth = 0;
-    wid = new wxSCIListBoxWin (GETWIN(parent.GetID()), ctrlID, location_);
+   
+/* C::B begin */
+    if(wid == 0)
+    {
+        wid = new wxSCIListBoxWin (GETWIN(parent.GetID()), ctrlID, location_);
+    }
+    else if(GETLBW(wid)->GetParent() != GETWIN(parent.GetID()))
+    {
+        GETLBW(wid)->Reparent(GETWIN(parent.GetID()));
+    }
+    GETLBW(wid)->SetPosition(wxPoint(location_.x,location_.y));
+    GETLBW(wid)->SetId(ctrlID);
+    GETLB(wid)->SetId(ctrlID);
+/* C::B end */
+   
     if (imgList != NULL)
         GETLB(wid)->SetImageList(imgList, wxIMAGE_LIST_SMALL);
     /* C::B begin */
Index: src/sdk/wxscintilla/src/scintilla/src/AutoComplete.cxx
===================================================================
--- src/sdk/wxscintilla/src/scintilla/src/AutoComplete.cxx (wersja 8739)
+++ src/sdk/wxscintilla/src/scintilla/src/AutoComplete.cxx (kopia robocza)
@@ -57,9 +57,11 @@
 void AutoComplete::Start(Window &parent, int ctrlID,
  int position, Point location, int startLen_,
  int lineHeight, bool unicodeMode, int technology) {
- if (active) {
- Cancel();
- }
+/* C::B begin */
+// if (active) {
+// Cancel();
+// }
+/* C::B end */
  lb->Create(parent, ctrlID, location, lineHeight, unicodeMode, technology);
  lb->Clear();
  active = true;
@@ -124,7 +126,10 @@
 void AutoComplete::Cancel() {
  if (lb->Created()) {
  lb->Clear();
- lb->Destroy();
+/* C::B begin */
+ //lb->Destroy();
+ lb->Show(false);
+/* C::B end */
  active = false;
  }
 }

--- End code ---
It hides autocomplete window instead of deleting it. It should improve performance. And with this patch applied dynamic filtering will be possible.

Alpha:

--- Quote from: p2rkw on January 04, 2013, 04:29:31 pm ---And with this patch applied dynamic filtering will be possible.

--- End quote ---
Maybe no one noticed, but I thought I would mention, the trunk already uses a little dynamic filtering.  If you type:

--- Code: ---#include <wx/aui

--- End code ---
as soon as the next directory is entered:

--- Code: ---#include <wx/aui/

--- End code ---
the listing is refined.  Assuming auto-launch characters is set to 3 (and you are going for cbStyledTextCtrl),

--- Code: ---cbS

--- End code ---
will launch the box, and typing auto-launch + 4 more:

--- Code: ---cbStyle

--- End code ---
causes the listing to be refined.
That said, the filtering is currently forced to re-build the box, so there are brief pauses when it disappears, then reappears.

Navigation

[0] Message Index

[#] Next page

Go to full version