From: Antoine Fontaine Date: Sun, 21 Mar 2021 00:03:58 +0000 (+0100) Subject: Fix GTK_CRITICAL errors X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=6ed444ce55f3a5c07f4d4a8625352f239dd1f25b;p=xonotic%2Fnetradiant.git Fix GTK_CRITICAL errors --- diff --git a/libs/gtkutil/dialog.cpp b/libs/gtkutil/dialog.cpp index aa8aad47..66470543 100644 --- a/libs/gtkutil/dialog.cpp +++ b/libs/gtkutil/dialog.cpp @@ -86,8 +86,9 @@ gboolean modal_dialog_delete( ui::Widget widget, GdkEvent* event, ModalDialog* d } EMessageBoxReturn modal_dialog_show( ui::Window window, ModalDialog& dialog ){ - gtk_grab_add( window ); window.show(); + g_assert( GTK_IS_WINDOW(window) ); + gtk_grab_add( GTK_WIDGET(window) ); dialog.loop = true; while ( dialog.loop ) diff --git a/libs/gtkutil/glwidget.cpp b/libs/gtkutil/glwidget.cpp index 7ab8ebe6..31f5bbda 100644 --- a/libs/gtkutil/glwidget.cpp +++ b/libs/gtkutil/glwidget.cpp @@ -98,6 +98,7 @@ bool glwidget_make_current(ui::GLArea self) void glwidget_swap_buffers(ui::GLArea self) { + g_assert(GTK_IS_GL_AREA(self)); gtk_gl_area_queue_render(self); } diff --git a/radiant/mainframe.cpp b/radiant/mainframe.cpp index 332d7379..f39805bf 100644 --- a/radiant/mainframe.cpp +++ b/radiant/mainframe.cpp @@ -1804,9 +1804,11 @@ void Selection_SnapToGrid(){ static gint qe_every_second( gpointer data ){ - GdkModifierType mask; + if (g_pParentWnd == nullptr) + return TRUE; - gdk_window_get_pointer( 0, 0, 0, &mask ); + GdkModifierType mask; + gdk_window_get_pointer( gtk_widget_get_window(g_pParentWnd->m_window), nullptr, nullptr, &mask ); if ( ( mask & ( GDK_BUTTON1_MASK | GDK_BUTTON2_MASK | GDK_BUTTON3_MASK ) ) == 0 ) { QE_CheckAutoSave(); @@ -1918,15 +1920,18 @@ void ScreenUpdates_Disable( const char* message, const char* title ){ bool isActiveApp = MainFrame_isActiveApp(); g_wait = create_wait_dialog( title, message ); - gtk_grab_add( g_wait.m_window ); if ( isActiveApp ) { g_wait.m_window.show(); + gtk_grab_add( g_wait.m_window ); ScreenUpdates_process(); } } else if ( g_wait.m_window.visible() ) { g_wait.m_label.text(message); + if ( GTK_IS_WINDOW(g_wait.m_window) ) { + gtk_grab_add(g_wait.m_window); + } ScreenUpdates_process(); } g_wait_stack.push_back( message ); @@ -3299,7 +3304,7 @@ void MainFrame::SetStatusText( CopiedString& status_text, const char* pText ){ } void Sys_Status( const char* status ){ - if ( g_pParentWnd != 0 ) { + if ( g_pParentWnd != nullptr ) { g_pParentWnd->SetStatusText( g_pParentWnd->m_command_status, status ); } } @@ -3331,7 +3336,7 @@ void MainFrame::SetGridStatus(){ } void GridStatus_onTextureLockEnabledChanged(){ - if ( g_pParentWnd != 0 ) { + if ( g_pParentWnd != nullptr ) { g_pParentWnd->SetGridStatus(); } }