From 60692ba238c6c5c003722ccaa52702e9ef3ade13 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Fri, 1 Nov 2019 11:39:13 +0000 Subject: the label sync button will relaunch itself from its close handler MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit so rearrange things so that runAsync can survive that Change-Id: I7d40637fb861ceb64ce32f0e9ecb3451c0d17bad Reviewed-on: https://gerrit.libreoffice.org/81884 Tested-by: Jenkins Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- vcl/unx/gtk3/gtk3gtkinst.cxx | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) (limited to 'vcl') diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx index 6c318ce0bb91..1c225335753a 100644 --- a/vcl/unx/gtk3/gtk3gtkinst.cxx +++ b/vcl/unx/gtk3/gtk3gtkinst.cxx @@ -4117,7 +4117,7 @@ public: return; if (GTK_IS_DIALOG(m_pDialog)) sort_native_button_order(GTK_BOX(gtk_dialog_get_action_area(GTK_DIALOG(m_pDialog)))); - gtk_widget_show(m_pWidget); + GtkInstanceWindow::show(); } virtual void set_modal(bool bModal) override @@ -6030,29 +6030,30 @@ void GtkInstanceDialog::asyncresponse(gint ret) if (get_modal()) m_aDialogRun.dec_modal_count(); hide(); - m_aFunc(GtkToVcl(ret)); - if (m_nResponseSignalId) - { - g_signal_handler_disconnect(m_pDialog, m_nResponseSignalId); - m_nResponseSignalId = 0; - } - if (m_nCancelSignalId) - { - g_signal_handler_disconnect(m_pDialog, m_nCancelSignalId); - m_nCancelSignalId = 0; - } + // move the self pointer, otherwise it might be de-allocated by time we try to reset it + auto xRunAsyncSelf = std::move(m_xRunAsyncSelf); + auto xDialogController = std::move(m_xDialogController); + auto aFunc = std::move(m_aFunc); + + auto nResponseSignalId = m_nResponseSignalId; + auto nCancelSignalId = m_nCancelSignalId; + auto nSignalDeleteId = m_nSignalDeleteId; + m_nResponseSignalId = 0; + m_nCancelSignalId = 0; + m_nSignalDeleteId = 0; + + aFunc(GtkToVcl(ret)); + + if (nResponseSignalId) + g_signal_handler_disconnect(m_pDialog, nResponseSignalId); + if (nCancelSignalId) + g_signal_handler_disconnect(m_pDialog, nCancelSignalId); if (m_nSignalDeleteId) - { - g_signal_handler_disconnect(m_pDialog, m_nSignalDeleteId); - m_nSignalDeleteId = 0; - } + g_signal_handler_disconnect(m_pDialog, nSignalDeleteId); - m_aFunc = nullptr; - // move the self pointer, otherwise it might be de-allocated by time we try to reset it - std::shared_ptr me = std::move(m_xRunAsyncSelf); - m_xDialogController.reset(); - me.reset(); + xDialogController.reset(); + xRunAsyncSelf.reset(); } int GtkInstanceDialog::run() -- cgit