documentor: Fixed crash on double click outside editable text
authorJerome St-Louis <jerome@ecere.com>
Tue, 27 Aug 2013 02:55:49 +0000 (22:55 -0400)
committerJerome St-Louis <jerome@ecere.com>
Tue, 27 Aug 2013 02:55:49 +0000 (22:55 -0400)
documentor/src/Documentor.ec

index 4a088c8..d7b3ae0 100644 (file)
@@ -2365,32 +2365,35 @@ class HelpView : HTMLView
 
    bool OnLeftDoubleClick(int mx, int my, Modifiers mods)
    {
-      int c;
-      int start = -1;
-      int numBytes;
-      for(c = curPosition; c >= 0; c--)
-      {
-         unichar ch;
-         while(c > 0 && !UTF8_IS_FIRST(textBlock.text[c])) c--;
-         ch = UTF8GetChar(textBlock.text + c, &numBytes);
-         if(!CharMatchCategories(ch, letters|numbers|marks|connector))
-            break;
-         start = c;
-      }
-      if(start != -1)
+      if(edit && textBlock)
       {
-         for(c = start; c < textBlock.textLen; c += numBytes)
+         int c;
+         int start = -1;
+         int numBytes;
+         for(c = curPosition; c >= 0; c--)
          {
-            unichar ch = UTF8GetChar(textBlock.text + c, &numBytes);
+            unichar ch;
+            while(c > 0 && !UTF8_IS_FIRST(textBlock.text[c])) c--;
+            ch = UTF8GetChar(textBlock.text + c, &numBytes);
             if(!CharMatchCategories(ch, letters|numbers|marks|connector))
                break;
+            start = c;
          }
-         selPosition = start;
-         curPosition = c;
+         if(start != -1)
+         {
+            for(c = start; c < textBlock.textLen; c += numBytes)
+            {
+               unichar ch = UTF8GetChar(textBlock.text + c, &numBytes);
+               if(!CharMatchCategories(ch, letters|numbers|marks|connector))
+                  break;
+            }
+            selPosition = start;
+            curPosition = c;
 
-         PositionCaret(true);
-         Update(null);
-         return false;
+            PositionCaret(true);
+            Update(null);
+            return false;
+         }
       }
       return true;
    }