r17603 by jghali - #10774: crash on clicking on text frame

scribus-commit scribus-commit at lists.scribus.net
Fri Jun 22 01:32:56 UTC 2012


Author: jghali
Date: Fri Jun 22 01:32:56 2012
New Revision: 17603

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=17603
Log:
#10774: crash on clicking on text frame

Modified:
    trunk/Scribus/scribus/canvasmode_edit.cpp

Modified: trunk/Scribus/scribus/canvasmode_edit.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17603&path=/trunk/Scribus/scribus/canvasmode_edit.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasmode_edit.cpp (original)
+++ trunk/Scribus/scribus/canvasmode_edit.cpp Fri Jun 22 01:32:56 2012
@@ -318,14 +318,18 @@
 			else
 			{	//Double click in a frame to select a word
 				oldCp = currItem->itemText.cursorPosition();
-				if (currItem->itemText.hasObject(oldCp))
+				bool validPos = (oldCp >= 0 && oldCp < currItem->itemText.length());
+				if (validPos && currItem->itemText.hasObject(oldCp))
 				{
 					currItem->itemText.select(oldCp, 1, true);
 					PageItem *iItem = currItem->itemText.object(oldCp);
 					m_ScMW->editInlineStart(iItem->inlineCharID);
 				}
 				else
-					currItem->itemText.setCursorPosition(currItem->itemText.selectWord(currItem->itemText.cursorPosition()));
+				{
+					int newPos = currItem->itemText.selectWord(oldCp);
+					currItem->itemText.setCursorPosition(newPos);
+				}
 			}
 			currItem->HasSel = (currItem->itemText.lengthOfSelection() > 0);
 		}




More information about the scribus-commit mailing list