]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk/textctrl.cpp
don't crash if m_widget == NULL in OnInternalIdle()
[wxWidgets.git] / src / gtk / textctrl.cpp
index 5acaf96dafcf02c2c7b2926341ad3b41b4c23949..b9671b28503b39c6ff6b36340a35d66476145b8e 100644 (file)
@@ -521,9 +521,9 @@ gtk_text_exposed_callback( GtkWidget *widget, GdkEventExpose *event, wxTextCtrl
 //  wxTextCtrl
 //-----------------------------------------------------------------------------
 
-IMPLEMENT_DYNAMIC_CLASS(wxTextCtrl,wxControl)
+IMPLEMENT_DYNAMIC_CLASS(wxTextCtrl, wxTextCtrlBase)
 
-BEGIN_EVENT_TABLE(wxTextCtrl, wxControl)
+BEGIN_EVENT_TABLE(wxTextCtrl, wxTextCtrlBase)
     EVT_CHAR(wxTextCtrl::OnChar)
 
     EVT_MENU(wxID_CUT, wxTextCtrl::OnCut)
@@ -943,19 +943,25 @@ bool wxTextCtrl::PositionToXY(long pos, long *x, long *y ) const
     if ( m_windowStyle & wxTE_MULTILINE )
     {
         GtkTextIter iter;
-        gtk_text_buffer_get_iter_at_offset(m_buffer, &iter, pos);
-        if (gtk_text_iter_is_end(&iter))
+
+        if (pos > GetLastPosition())
             return false;
 
-        *y = gtk_text_iter_get_line(&iter);
-        *x = gtk_text_iter_get_line_offset(&iter);
+        gtk_text_buffer_get_iter_at_offset(m_buffer, &iter, pos);
+
+        if ( y )
+            *y = gtk_text_iter_get_line(&iter);
+        if ( x )
+            *x = gtk_text_iter_get_line_offset(&iter);
     }
     else // single line control
     {
         if ( pos <= GTK_ENTRY(m_text)->text_length )
         {
-            *y = 0;
-            *x = pos;
+            if ( y )
+                *y = 0;
+            if ( x )
+                *x = pos;
         }
         else
         {