Author Topic: crash when double click the selected text!  (Read 21021 times)

mikeandmore

  • Guest
crash when double click the selected text!
« on: April 01, 2006, 06:53:51 am »
1.select an part of text
2.double click on them
3.your cpu is ok,ram is ok,other app are ok,but CB made the whole sreen locked and no response at all.
4.restart your PC,and you have lost all the data which you didn't save.
« Last Edit: April 01, 2006, 12:00:46 pm by mikeandmore »

takeshimiya

  • Guest
Re: crash again!!!
« Reply #1 on: April 01, 2006, 08:29:58 am »
Let me guess... linux right?
That happened to me sometimes, and the 'double click' thing is probably a small drag&drop state.
Somehow dragging anything may cause segfaults. Dragging panels, dragging toolbars, dragging tabs. But the crashes are more often presented when dragging text. It's like it 'hangs' in a drag&drop state.

Offline gfgfd

  • Multiple posting newcomer
  • *
  • Posts: 10
Re: crash again!!!
« Reply #2 on: April 01, 2006, 10:29:39 am »
hapends to me atleast once every day :(
use shortcuts to save & quit when cb locks screen like that. ctrl+shift+s to save and ctrl+q to quit.. and if that fails use ctrl+alt+f2 to switch to console, login and 'killall codeblocks'.

takeshimiya

  • Guest
Re: crash again!!!
« Reply #3 on: April 01, 2006, 10:36:30 am »
hapends to me atleast once every day :(
use shortcuts to save & quit when cb locks screen like that. ctrl+shift+s to save and ctrl+q to quit.. and if that fails use ctrl+alt+f2 to switch to console, login and 'killall codeblocks'.
Heh, yes, most of times the keywoard still works, what seems to hand is the interface with the mouse (in a drag&drop state).

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2874
Re: crash again!!!
« Reply #4 on: April 01, 2006, 04:41:56 pm »
Let me guess... linux right?
That happened to me sometimes, and the 'double click' thing is probably a small drag&drop state.
Somehow dragging anything may cause segfaults. Dragging panels, dragging toolbars, dragging tabs. But the crashes are more often presented when dragging text. It's like it 'hangs' in a drag&drop state.


Have you tried getting the crash with all but compiler
turned off. Is this a plugin problem?

thanks
pecan

takeshimiya

  • Guest
Re: crash again!!!
« Reply #5 on: April 01, 2006, 04:59:51 pm »
Have you tried getting the crash with all but compiler
turned off. Is this a plugin problem?

I think it's not only one problem, it's multiple problems.
I can reproduce the hang with SciTE when dragging text on linux, so that could mean that the problem is either in Scintilla, or GTK2.

BUT, I also get hangs when dragging toolbars/panels/tabs, so they could be the same bug, or different bugs, for instance in Scintilla, GTK, wxWidgets, wxAUI, C::B, ...

mikeandmore

  • Guest
Re: crash when double click the selected text!
« Reply #6 on: April 01, 2006, 05:59:33 pm »
it's the wxscintilla 's problem,i think

for scite and gtk apps works.
amule and other wx apps works.

for wxscintilla i dono.at lease CB "crash"

mikeandmore

  • Guest
Re: crash when double click the selected text!
« Reply #7 on: April 01, 2006, 06:09:56 pm »
i got it! :D

It is wxscintilla's bug,MingStudio also has that bug!!!
but SciTE and GTK apps is OK!

takeshimiya

  • Guest
Re: crash when double click the selected text!
« Reply #8 on: April 01, 2006, 06:14:46 pm »
i got it! :D

It is wxscintilla's bug,MingStudio also has that bug!!!
but SciTE and GTK apps is OK!

I have experienced it with SciTE too...

Again, it could be different unrelated (or related?) bugs.

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2874
Re: crash when double click the selected text!
« Reply #9 on: April 01, 2006, 08:12:54 pm »
it's the wxscintilla 's problem,i think

Yep, wxScintilla.
Notice that when dragging, scintilla places a "page" cursor along with the "+" cursor of gtk when dragging a marked area.
Notice also, that the "page" cursor is missing when you double click on a marked area.

Scintilla and GTK are not in sync. GTK thinks the drag is occuring while scintilla thinks a double click is supposed
to unmark the marked area. No one is telling GTK the drag is over. Its a deadly embrace.

CB is running on 1.62 scintilla. What other version of scintilla are behaving correctly on GTK? That ought to give us a clue.

Offline Michael

  • Lives here!
  • ****
  • Posts: 1608
Re: crash when double click the selected text!
« Reply #10 on: April 01, 2006, 08:21:09 pm »
CB is running on 1.62 scintilla. What other version of scintilla are behaving correctly on GTK? That ought to give us a clue.

May be wxScintilla 1.68 would solve the problem.

Best wishes,
Michael

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2874
Re: crash when double click the selected text!
« Reply #11 on: April 01, 2006, 08:35:55 pm »
CB is running on 1.62 scintilla. What other version of scintilla are behaving correctly on GTK? That ought to give us a clue.

May be wxScintilla 1.68 would solve the problem.

Best wishes,
Michael


I looked over the bug list at http://scintilla.sourceforge.net/ScintillaHistory.html
and found nothing about the bug. Disappointing....


mikeandmore

  • Guest
Re: crash when double click the selected text!
« Reply #12 on: April 02, 2006, 03:20:42 am »
confirm wxsintilla 1.67 also have this bug.(the sample program)

Allefant

  • Guest
Re: crash when double click the selected text!
« Reply #13 on: April 03, 2006, 01:16:55 am »
I'm also seeing this, also filed a bug report about it: https://developer.berlios.de/bugs/?func=detailbug&bug_id=6884&group_id=5358

So, seems the reply in the bug report that a newer WX fixes it was just a guess? I wonder if the WxScintilla devs know about it..

Offline Michael

  • Lives here!
  • ****
  • Posts: 1608
Re: crash when double click the selected text!
« Reply #14 on: April 03, 2006, 01:36:30 am »
[...]I wonder if the WxScintilla devs know about it..

Hello,

you can also try to post a bug report there.

Best wishes,
Michael

mikeandmore

  • Guest
Re: crash when double click the selected text!
« Reply #15 on: April 13, 2006, 11:25:31 am »
i fixed this bug myself
but i don't think it will work with the drag-and-drop plugin in codebloks any more.


[attachment deleted by admin]

Offline Michael

  • Lives here!
  • ****
  • Posts: 1608
Re: crash when double click the selected text!
« Reply #16 on: April 13, 2006, 01:16:02 pm »
i fixed this bug myself
but i don't think it will work with the drag-and-drop plugin in codebloks any more.

You can post the patch to BerliOS.

Best wishes,
Michael

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2874
Re: crash when double click the selected text!
« Reply #17 on: April 13, 2006, 04:27:04 pm »
i fixed this bug myself
but i don't think it will work with the drag-and-drop plugin in codebloks any more.

Code
--- wxscintilla_1.67.0.orig/include/wx/wxscintilla.h	2005-12-22 01:25:58.000000000 +0800
+++ wxscintilla_1.67.0/include/wx/wxscintilla.h 2006-04-13 17:06:38.000000000 +0800
@@ -3437,9 +3437,9 @@ BEGIN_DECLARE_EVENT_TYPES()
     DECLARE_EXPORTED_EVENT_TYPE (WXDLLIMPEXP_SCI, wxEVT_SCI_URIDROPPED,         1666)
     DECLARE_EXPORTED_EVENT_TYPE (WXDLLIMPEXP_SCI, wxEVT_SCI_DWELLSTART,         1667)
     DECLARE_EXPORTED_EVENT_TYPE (WXDLLIMPEXP_SCI, wxEVT_SCI_DWELLEND,           1668)
-    DECLARE_EXPORTED_EVENT_TYPE (WXDLLIMPEXP_SCI, wxEVT_SCI_START_DRAG,         1669)
-    DECLARE_EXPORTED_EVENT_TYPE (WXDLLIMPEXP_SCI, wxEVT_SCI_DRAG_OVER,          1670)
-    DECLARE_EXPORTED_EVENT_TYPE (WXDLLIMPEXP_SCI, wxEVT_SCI_DO_DROP,            1671)
+    //DECLARE_EXPORTED_EVENT_TYPE (WXDLLIMPEXP_SCI, wxEVT_SCI_START_DRAG,         1669)
+    //DECLARE_EXPORTED_EVENT_TYPE (WXDLLIMPEXP_SCI, wxEVT_SCI_DRAG_OVER,          1670)
+    //DECLARE_EXPORTED_EVENT_TYPE (WXDLLIMPEXP_SCI, wxEVT_SCI_DO_DROP,            1671)
     DECLARE_EXPORTED_EVENT_TYPE (WXDLLIMPEXP_SCI, wxEVT_SCI_ZOOM,               1672)
     DECLARE_EXPORTED_EVENT_TYPE (WXDLLIMPEXP_SCI, wxEVT_SCI_HOTSPOT_CLICK,      1673)
     DECLARE_EXPORTED_EVENT_TYPE (WXDLLIMPEXP_SCI, wxEVT_SCI_HOTSPOT_DCLICK,     1674)

This patch appears to disable drag and drop for *all* platforms.
I've only experienced the bug under wxGTK.
« Last Edit: April 13, 2006, 04:28:35 pm by Pecan »

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2874
Re: crash when double click the selected text!
« Reply #18 on: May 07, 2006, 09:17:18 pm »
Would someone tell me how to apply a patch with svn command line utilities on   Linux.

I created a scintilla patch but was using a test program. Now I want to apply and test on CodeBlocks. I cannot seem to find a "patch" command.

What am I missing?

thanks
pecan

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: crash when double click the selected text!
« Reply #19 on: May 07, 2006, 09:56:32 pm »
Create patch:
svn diff > filename.patch

Apply patch:
patch -p0 -u < filename.patch is the "correct" way, but
patch -p0  < filename.patch is what the svn documentation recommends.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2874
Re: crash when double click the selected text!
« Reply #20 on: May 08, 2006, 12:31:28 am »
Since berlios is down again, I'll submit this proposed patch to the forum. Maybe someone can confirm it for me.

This patch will lessen the occurance of the drag'n'drop hang that occurs with GTK and Scintilla. This is actually a GTK bug, but is aggravated by the manner in which  Scintilla coded a double click.

The hang occurs because GTK and wxGTK are out of synch and cannot handle a mouse key up event while also handling a mouse moving event. So the mouse key up event is lost. But while dragging, wxGTK is depending on the key up to end the drag. Once the hang occurs, no more mouse events are ever seen by wxGTK because the underlying OS has the mouse in drag capture.

This "fix"  moves the Scintilla drag initiation out of the mouse ButtonDown code and into the ButtonMove code to avoid the ButtonDown double click problem. Having the code in ButtonDown exacerbates the problem by entering the drag code over and over again. The "fix" enters the drag initiation only once, and only if the key is already down and the mouse is moving. It will not initiate another drag until a subsequent mouse ButtonUp.

The hang can still occur (until the GTK/wxGTK bug is fixed), but only if you try really really hard.

Code
Index: src/scintilla/src/Editor.cxx
===================================================================
--- src/scintilla/src/Editor.cxx (revision 2387)
+++ src/scintilla/src/Editor.cxx (working copy)
@@ -5,6 +5,18 @@
 // Copyright 1998-2004 by Neil Hodgson <neilh@scintilla.org>
 // The License.txt file describes the conditions under which this software may be distributed.
 
+//Lines tagged //pecan 20060506 is a patch to avoid the GTK drag'n'drop hang bug.
+//GTK is not handling a mouse "moving buttonUp" event well. The keyUp event is completely missed
+// causing wxGTK to hang in the drag routine waiting for the up event.GTK has the mouse captured,
+// so no event will ever be seen by wxGTK.
+//This is aggravated by the manner in which scintilla coded the mouse doubleClick.
+// It treats it as two single ButtonDown clicks, entering DragNdrop over and over again.
+//This patch moves the initiation of the drag into the MouseMove code to avoid the double click
+// problem. It will not allow secondary drags until a subsequent mouse up event.
+//This patch does not cure the problem, it can still happen if the user quickly drags
+// and lifts the mouse key at the same time the mouse is moving. But it's much harder
+// to cause the hang. Pecan
+
 #include <stdlib.h>
 #include <string.h>
 #include <stdio.h>
@@ -442,6 +454,9 @@
  hsEnd = -1;
 
  llc.SetLevel(LineLayoutCache::llcCaret);
+ #ifdef __WXGTK__
+ m_mouseButtonDownCnt = 0;   //pecan 20060507
+ #endif
 }
 
 Editor::~Editor() {
@@ -1212,7 +1227,7 @@
 where most code reside, and the lines after the caret, eg. the body of a function.
 
      |        |       |      |                                            |
-slop | strict | jumps | even | Caret can go to the margin                 | When reaching limitÝ(caret going out of
+slop | strict | jumps | even | Caret can go to the margin                 | When reaching limit (caret going out of
      |        |       |      |                                            | visibility or going into the UZ) display is...
 -----+--------+-------+------+--------------------------------------------+--------------------------------------------------------------
   0  |   0    |   0   |   0  | Yes                                        | moved to put caret on top/on right
@@ -5037,6 +5052,9 @@
 
 void Editor::ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, bool alt) {
  //Platform::DebugPrintf("Scintilla:ButtonDown %d %d = %d alt=%d\n", curTime, lastClickTime, curTime - lastClickTime, alt);
+ #ifdef __WXGTK__
+ m_mouseButtonDownCnt++;    //pecan 20060507
+ #endif
  ptMouseLast = pt;
  int newPos = PositionFromLocation(pt);
  newPos = MovePositionOutsideChar(newPos, currentPos - newPos);
@@ -5124,12 +5142,18 @@
  }
  if (!shift) {
  inDragDrop = PointInSelection(pt) && !SelectionEmpty();
+ #ifdef __WXGTK__
+ if (m_mouseButtonDownCnt>1)     //pecan 20060507
+                    inDragDrop = false;         //pecan 20060507
+                #endif
  }
  if (inDragDrop) {
+     #ifndef __WXGTK__       //for GTK, code moved to ButtonMove() //pecan 20060507
  SetMouseCapture(false);
  SetDragPosition(newPos);
  CopySelectionRange(&drag);
  StartDrag();
+ #endif
  } else {
  SetDragPosition(invalidPosition);
  SetMouseCapture(true);
@@ -5203,6 +5227,18 @@
  }
  ptMouseLast = pt;
  //Platform::DebugPrintf("Move %d %d\n", pt.x, pt.y);
+    #ifdef __WXGTK__        //pecan 20060507
+    // code moved here from ButtonDown to avoid GTK doubleClick/drag hang bug
+    if (inDragDrop) {
+        SetMouseCapture(false);
+        int newPos = PositionFromLocation(pt);
+        SetDragPosition(newPos);
+        CopySelectionRange(&drag);
+        m_mouseButtonDownCnt++; //don't do again until mouse ButtonUp //pecan 20060507
+        StartDrag();
+    }
+    #endif  //pecan 20060507
+
  if (HaveMouseCapture()) {
 
  // Slow down autoscrolling/selection
@@ -5289,7 +5325,10 @@
 }
 
 void Editor::ButtonUp(Point pt, unsigned int curTime, bool ctrl) {
- //Platform::DebugPrintf("ButtonUp %d\n", HaveMouseCapture());
+ //Platform::DebugPrintf("ButtonUp mouseCapture%d downCnt:%d", HaveMouseCapture(), m_mouseButtonDownCnt);
+ #ifdef __WXGTK__
+ m_mouseButtonDownCnt = 0;   //pecan 20060507
+ #endif
  if (HaveMouseCapture()) {
  if (PointInSelMargin(pt)) {
  DisplayCursor(Window::cursorReverseArrow);
Index: src/scintilla/src/Editor.h
===================================================================
--- src/scintilla/src/Editor.h (revision 2387)
+++ src/scintilla/src/Editor.h (working copy)
@@ -528,6 +528,8 @@
 
  virtual sptr_t DefWndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) = 0;
 
+ int m_mouseButtonDownCnt;   //pecan 20060507
+
 public:
  // Public so the COM thunks can access it.
  bool IsUnicodeMode() const;

The line with "-slop" in it has nothing to do with the patch. But svn keeps putting it back into my source. When I save the file, svn now thinks the line is changed. Darn it ! It does no harm, though.

Will submit patch to Berlios when it comes back up.

thanks
pecan
« Last Edit: May 08, 2006, 12:36:45 am by Pecan »

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: crash when double click the selected text!
« Reply #21 on: May 08, 2006, 12:56:45 am »
Quote
Since berlios is down again
Works without any problems?  :shock:
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline JThedering

  • Single posting newcomer
  • *
  • Posts: 9
Re: crash when double click the selected text!
« Reply #22 on: June 13, 2006, 12:55:23 am »
Just because nobody mentioned it:
You can get out of the bad state by Alt-F (or any other menu shortcut). When the menu opens, the mouse cursor will be ok again.

moloh

  • Guest
Re: crash when double click the selected text!
« Reply #23 on: June 13, 2006, 10:59:43 am »
Just because nobody mentioned it:
You can get out of the bad state by Alt-F (or any other menu shortcut). When the menu opens, the mouse cursor will be ok again.

Ow, so this is that problem, but earlier i didn't know how exacly i triggerd this behaviour... now i know ;-).
I confirm this. Workaround too.