Fix crash when using wxNotebook with glib 2.73 or later

Make GTK notebook log suppression opt-in to avoid a fatal error when the
application calls g_log_set_writer_func() itself, as doing it more than
once immediately kills the application with glib 2.73 and there is no
way to check if it had been already done or not (you have to admire the
purity of the API design here).

This is unfortunate as 99% of the wxWidgets applications that do _not_
call g_log_set_writer_func() would now show the spurious diagnostics by
default again, but preferable to making the remaining 1% crash, and
there doesn't seem to be any other solution.

Call the new GTKAllowDiagnosticsControl() function in the notebook
sample to at least still avoid getting the spurious diagnostic messages
described in #22176 there.

See #22717,.
This commit is contained in:
Vadim Zeitlin 2022-08-29 15:46:28 +02:00
parent 82cb8aa859
commit 8af645ed22
6 changed files with 65 additions and 1 deletions

View file

@ -37,6 +37,13 @@ bool MyApp::OnInit()
if ( !wxApp::OnInit() )
return false;
#ifdef __WXGTK__
// Many version of wxGTK generate spurious diagnostic messages when
// destroying wxNotebook (or removing pages from it), allow wxWidgets to
// suppress them.
GTKAllowDiagnosticsControl();
#endif // __WXGTK__
#if wxUSE_HELP
wxHelpProvider::Set( new wxSimpleHelpProvider );
#endif