[Libreoffice-commits] core.git: vcl/inc vcl/unx

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Tue May 11 07:44:42 UTC 2021


 vcl/inc/unx/gtk/gtkdata.hxx |   11 +++++++++++
 vcl/unx/gtk3/gtkframe.cxx   |   10 +---------
 vcl/unx/gtk3/gtkinst.cxx    |   28 ++++++----------------------
 vcl/unx/gtk3/gtksalmenu.cxx |   11 ++---------
 4 files changed, 20 insertions(+), 40 deletions(-)

New commits:
commit 65543a53c4058a6e491bc3ef8ca71970a1bc50b7
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Mon May 10 20:25:28 2021 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Tue May 11 09:43:50 2021 +0200

    gtk4: centralize g_main_loop_run ifdefry
    
    Change-Id: I1a984783cf4c39500ab6dfdb59e5d1c604de4b5b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115361
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/vcl/inc/unx/gtk/gtkdata.hxx b/vcl/inc/unx/gtk/gtkdata.hxx
index 2a741e855b94..ddf8a4b63aec 100644
--- a/vcl/inc/unx/gtk/gtkdata.hxx
+++ b/vcl/inc/unx/gtk/gtkdata.hxx
@@ -53,6 +53,17 @@ inline ::Window widget_get_xid(GtkWidget *widget)
 }
 #endif
 
+inline void main_loop_run(GMainLoop* pLoop)
+{
+#if !GTK_CHECK_VERSION(4, 0, 0)
+    gdk_threads_leave();
+#endif
+    g_main_loop_run(pLoop);
+#if !GTK_CHECK_VERSION(4, 0, 0)
+    gdk_threads_enter();
+#endif
+}
+
 class GtkSalTimer final : public SalTimer
 {
     struct SalGtkTimeoutSource *m_pTimeout;
diff --git a/vcl/unx/gtk3/gtkframe.cxx b/vcl/unx/gtk3/gtkframe.cxx
index f8effa137620..610fdb5ebd1f 100644
--- a/vcl/unx/gtk3/gtkframe.cxx
+++ b/vcl/unx/gtk3/gtkframe.cxx
@@ -4112,15 +4112,7 @@ public:
             gtk_drag_get_data(m_pWidget, m_pContext, it->second, m_nTime);
 
             if (g_main_loop_is_running(m_pLoop))
-            {
-#if !GTK_CHECK_VERSION(4, 0, 0)
-                gdk_threads_leave();
-#endif
-                g_main_loop_run(m_pLoop);
-#if !GTK_CHECK_VERSION(4, 0, 0)
-                gdk_threads_enter();
-#endif
-            }
+                main_loop_run(m_pLoop);
 
             g_main_loop_unref(m_pLoop);
             m_pLoop = nullptr;
diff --git a/vcl/unx/gtk3/gtkinst.cxx b/vcl/unx/gtk3/gtkinst.cxx
index c696627af246..b8ddee717811 100644
--- a/vcl/unx/gtk3/gtkinst.cxx
+++ b/vcl/unx/gtk3/gtkinst.cxx
@@ -4894,13 +4894,7 @@ struct DialogRunner
         m_pLoop = g_main_loop_new(nullptr, false);
         m_nResponseId = GTK_RESPONSE_NONE;
 
-#if !GTK_CHECK_VERSION(4, 0, 0)
-        gdk_threads_leave();
-#endif
-        g_main_loop_run(m_pLoop);
-#if !GTK_CHECK_VERSION(4, 0, 0)
-        gdk_threads_enter();
-#endif
+        main_loop_run(m_pLoop);
 
         g_main_loop_unref(m_pLoop);
 
@@ -5106,11 +5100,7 @@ private:
         gtk_menu_popup(GTK_MENU(pMenu), nullptr, nullptr, nullptr, nullptr, button, event_time);
 
         if (g_main_loop_is_running(pLoop))
-        {
-            gdk_threads_leave();
-            g_main_loop_run(pLoop);
-            gdk_threads_enter();
-        }
+            main_loop_run(pLoop);
 
         g_main_loop_unref(pLoop);
         g_signal_handler_disconnect(pMenu, nSignalId);
@@ -8645,11 +8635,8 @@ private:
         }
 
         if (g_main_loop_is_running(pLoop))
-        {
-            gdk_threads_leave();
-            g_main_loop_run(pLoop);
-            gdk_threads_enter();
-        }
+            main_loop_run(pLoop);
+
         g_main_loop_unref(pLoop);
         g_signal_handler_disconnect(m_pMenu, nSignalId);
     }
@@ -8934,11 +8921,8 @@ public:
         }
 
         if (g_main_loop_is_running(pLoop))
-        {
-            gdk_threads_leave();
-            g_main_loop_run(pLoop);
-            gdk_threads_enter();
-        }
+            main_loop_run(pLoop);
+
         g_main_loop_unref(pLoop);
         g_signal_handler_disconnect(m_pMenu, nSignalId);
         gtk_menu_detach(m_pMenu);
diff --git a/vcl/unx/gtk3/gtksalmenu.cxx b/vcl/unx/gtk3/gtksalmenu.cxx
index b35bb59c14aa..ac28c3ca5961 100644
--- a/vcl/unx/gtk3/gtksalmenu.cxx
+++ b/vcl/unx/gtk3/gtksalmenu.cxx
@@ -536,15 +536,8 @@ bool GtkSalMenu::ShowNativePopupMenu(FloatingWindow* pWin, const tools::Rectangl
 #endif
 
     if (g_main_loop_is_running(pLoop))
-    {
-#if !GTK_CHECK_VERSION(4, 0, 0)
-        gdk_threads_leave();
-#endif
-        g_main_loop_run(pLoop);
-#if !GTK_CHECK_VERSION(4, 0, 0)
-        gdk_threads_enter();
-#endif
-    }
+        main_loop_run(pLoop);
+
     g_main_loop_unref(pLoop);
 
     mpVCLMenu->Deactivate();


More information about the Libreoffice-commits mailing list