]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk/textctrl.cpp
[ 1603286 ] make wxMessageDialog Gnome HIG conform for yes_no+cancel
[wxWidgets.git] / src / gtk / textctrl.cpp
index 08bb79660ba547a62cad2a3653ecf2aec516d968..48dbbd95a28f6ba36e21988c620834c09e6b987f 100644 (file)
@@ -1153,31 +1153,7 @@ int wxTextCtrl::GetNumberOfLines() const
 {
     if ( IsMultiLine() )
     {
-        GtkTextIter iter;
-        gtk_text_buffer_get_iter_at_offset( m_buffer, &iter, 0 );
-
-        // move forward by one display line until the end is reached
-        int lineCount = 1;
-        while ( gtk_text_view_forward_display_line(GTK_TEXT_VIEW(m_text), &iter) )
-        {
-            lineCount++;
-        }
-
-        // If the last character in the text buffer is a newline,
-        // gtk_text_view_forward_display_line() will return false without that
-        // line being counted. Must add one manually in that case.
-        GtkTextIter lastCharIter;
-        gtk_text_buffer_get_iter_at_offset
-        (
-            m_buffer,
-            &lastCharIter,
-            gtk_text_buffer_get_char_count(m_buffer) - 1
-        );
-        gchar lastChar = gtk_text_iter_get_char( &lastCharIter );
-        if ( lastChar == wxT('\n') )
-            lineCount++;
-
-        return lineCount;
+        return gtk_text_buffer_get_line_count( m_buffer );
     }
     else // single line
     {
@@ -1852,8 +1828,8 @@ void wxTextCtrl::Freeze()
             g_object_ref(m_buffer);
             GtkTextBuffer* buf_new = gtk_text_buffer_new(NULL);
             gtk_text_view_set_buffer(GTK_TEXT_VIEW(m_text), buf_new);
-            // gtk_text_view_set_buffer adds its own reference
-            g_object_unref(buf_new);
+            // FIXME: this leaks the new buffer, since gtk_text_view_set_buffer
+            // adds its own reference, but unrefing it here can cause a crash later
         }
     }
 }