summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2022-05-19 09:34:16 +0100
committerCaolán McNamara <caolanm@redhat.com>2022-05-19 12:47:23 +0200
commitd404f6c8b28bc9b298cd618ef6c0dd6d755bdc17 (patch)
tree76b7f8f0207a48b9e3c3383f0f3e70ae446f0274 /vcl
parent02f53bd61222d7999b847a22fd24d65195f129e5 (diff)
merge the g_bus_get_sync calls
Change-Id: I320feb6673f18d6d8d9c5afa9ab602b9405ec581 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134604 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/unx/gtk3/gtkframe.cxx19
1 files changed, 10 insertions, 9 deletions
diff --git a/vcl/unx/gtk3/gtkframe.cxx b/vcl/unx/gtk3/gtkframe.cxx
index 4c2aab8e7a28..9037b9eaf915 100644
--- a/vcl/unx/gtk3/gtkframe.cxx
+++ b/vcl/unx/gtk3/gtkframe.cxx
@@ -76,6 +76,12 @@ int GtkSalFrame::m_nFloats = 0;
static GDBusConnection* pSessionBus = nullptr;
+static void EnsureSessionBus()
+{
+ if (!pSessionBus)
+ pSessionBus = g_bus_get_sync(G_BUS_TYPE_SESSION, nullptr, nullptr);
+}
+
sal_uInt16 GtkSalFrame::GetKeyModCode( guint state )
{
sal_uInt16 nCode = 0;
@@ -541,8 +547,7 @@ static void attach_menu_model(GtkSalFrame* pSalFrame)
#if !GTK_CHECK_VERSION(4,0,0)
// Get a DBus session connection.
- if (!pSessionBus)
- pSessionBus = g_bus_get_sync (G_BUS_TYPE_SESSION, nullptr, nullptr);
+ EnsureSessionBus();
if (!pSessionBus)
return;
@@ -629,13 +634,9 @@ void GtkSalFrame::EnsureAppMenuWatch()
return;
// Get a DBus session connection.
- if ( pSessionBus == nullptr )
- {
- pSessionBus = g_bus_get_sync( G_BUS_TYPE_SESSION, nullptr, nullptr );
-
- if ( pSessionBus == nullptr )
- return;
- }
+ EnsureSessionBus();
+ if (!pSessionBus)
+ return;
// Publish the menu only if AppMenu registrar is available.
m_nWatcherId = g_bus_watch_name_on_connection( pSessionBus,