diff options
authorJustin Luth <>2015-10-16 20:41:12 +0300
committerMiklos Vajna <>2015-10-27 11:28:37 +0000
commit9f008e2ae5e9d090ca011e5a6146e221e6799531 (patch)
parentb392270d68d483a1566e7281c6400874a42ce4b3 (diff)
tdf#95096 avoid invalid cursor position exception
Somehow, accessible text can lose focus and so when attempting to set the cursor, the string we were just working with may no longer be available, so verify that the cursor position is still valid before setting it. If the text can just disappear like that, then potentially we are still forcing the cursor into the wrong place (since the string is different than expected). However we can at least make sure the program doesn't crash/exit without saving... Change-Id: I8dcaf4625d187cb75008bdc0af0e3a546090a018 Reviewed-on: Reviewed-by: Justin Luth <> Tested-by: Justin Luth <> (cherry picked from commit d9cf47449e88032803aa4fa3429cd607a074d5ad) Reviewed-on: Reviewed-by: Miklos Vajna <> Tested-by: Miklos Vajna <>
1 files changed, 5 insertions, 2 deletions
diff --git a/vcl/unx/gtk/window/gtksalframe.cxx b/vcl/unx/gtk/window/gtksalframe.cxx
index 347497c2acb9..980f0e4511d7 100644
--- a/vcl/unx/gtk/window/gtksalframe.cxx
+++ b/vcl/unx/gtk/window/gtksalframe.cxx
@@ -4689,9 +4689,12 @@ gboolean GtkSalFrame::IMHandler::signalIMDeleteSurrounding( GtkIMContext*, gint
if (nDeletePos < nPosition)
if (nDeleteEnd <= nPosition)
- xText->setCaretPosition( nPosition-(nDeleteEnd-nDeletePos) );
+ nPosition = nPosition - (nDeleteEnd - nDeletePos);
- xText->setCaretPosition( nDeletePos );
+ nPosition = nDeletePos;
+ if (xText->getCharacterCount() >= nPosition)
+ xText->setCaretPosition( nPosition );
return true;