From: Vadim Zeitlin Date: Fri, 23 Jul 2004 21:34:19 +0000 (+0000) Subject: don't crash if WriteText() argument can't be converted to UTF-8 X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/8e033d81f2bc6b457c04c8a435cd20dee42dcfed don't crash if WriteText() argument can't be converted to UTF-8 git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@28442 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/gtk/textctrl.cpp b/src/gtk/textctrl.cpp index 50783a1b0d..09059a3f00 100644 --- a/src/gtk/textctrl.cpp +++ b/src/gtk/textctrl.cpp @@ -593,6 +593,12 @@ void wxTextCtrl::WriteText( const wxString &text ) #else wxCharBuffer buffer( wxConvUTF8.cWC2MB( wxConvLocal.cWX2WC( text ) ) ); #endif + if ( !buffer ) + { + // what else can we do? at least don't crash... + return; + } + GtkTextBuffer *text_buffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW(m_text) ); // TODO: Call whatever is needed to delete the selection. diff --git a/src/gtk1/textctrl.cpp b/src/gtk1/textctrl.cpp index 50783a1b0d..09059a3f00 100644 --- a/src/gtk1/textctrl.cpp +++ b/src/gtk1/textctrl.cpp @@ -593,6 +593,12 @@ void wxTextCtrl::WriteText( const wxString &text ) #else wxCharBuffer buffer( wxConvUTF8.cWC2MB( wxConvLocal.cWX2WC( text ) ) ); #endif + if ( !buffer ) + { + // what else can we do? at least don't crash... + return; + } + GtkTextBuffer *text_buffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW(m_text) ); // TODO: Call whatever is needed to delete the selection.