vcl/unx/gtk/window/gtksalframe.cxx |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

New commits:
commit d9cf47449e88032803aa4fa3429cd607a074d5ad
Author: Justin Luth <justin_l...@sil.org>
Date:   Fri Oct 16 20:41:12 2015 +0300

    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: https://gerrit.libreoffice.org/19414
    Reviewed-by: Justin Luth <justin_l...@sil.org>
    Tested-by: Justin Luth <justin_l...@sil.org>

diff --git a/vcl/unx/gtk/window/gtksalframe.cxx 
b/vcl/unx/gtk/window/gtksalframe.cxx
index ebc8516..25f3fe5 100644
--- a/vcl/unx/gtk/window/gtksalframe.cxx
+++ b/vcl/unx/gtk/window/gtksalframe.cxx
@@ -4712,9 +4712,12 @@ gboolean 
GtkSalFrame::IMHandler::signalIMDeleteSurrounding( GtkIMContext*, gint
         if (nDeletePos < nPosition)
         {
             if (nDeleteEnd <= nPosition)
-                xText->setCaretPosition( nPosition-(nDeleteEnd-nDeletePos) );
+                nPosition = nPosition - (nDeleteEnd - nDeletePos);
             else
-                xText->setCaretPosition( nDeletePos );
+                nPosition = nDeletePos;
+
+            if (xText->getCharacterCount() >= nPosition)
+                xText->setCaretPosition( nPosition );
         }
         return true;
     }
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to