X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/0104114590256337b35eafcb544c650a30ce51f4..54b84891257f53e347c05852c55d126c1ea0def6:/src/gtk/textctrl.cpp

diff --git a/src/gtk/textctrl.cpp b/src/gtk/textctrl.cpp
index 64c069e006..6194b622bc 100644
--- a/src/gtk/textctrl.cpp
+++ b/src/gtk/textctrl.cpp
@@ -14,6 +14,7 @@
 #include "wx/textctrl.h"
 #include "wx/utils.h"
 #include "wx/intl.h"
+#include "wx/log.h"
 #include "wx/settings.h"
 
 #include <sys/types.h>
@@ -646,6 +647,14 @@ void wxTextCtrl::SetSelection( long from, long to )
 {
     wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") );
 
+    if ( (m_windowStyle & wxTE_MULTILINE) &&
+         !GTK_TEXT(m_text)->line_start_cache )
+    {
+        // tell the programmer that it didn't work
+        wxLogDebug(_T("Can't call SetSelection() before realizing the control"));
+        return;
+    }
+
     gtk_editable_select_region( GTK_EDITABLE(m_text), (gint)from, (gint)to );
 }