]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk1/textctrl.cpp
Fix for unsafe use of a global pointer for focus window: now checks at destruct
[wxWidgets.git] / src / gtk1 / textctrl.cpp
index 64c069e006a5a8e0408ec45c77b629d570c91a5a..6194b622bc2d71c3efd0df4bc4708587bd13aeb1 100644 (file)
@@ -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 );
 }