vcl/unx/gtk3/gtkinst.cxx | 127 ++++++++++++++++++++++++++--------------------- 1 file changed, 71 insertions(+), 56 deletions(-)
New commits: commit 261d2ec2ab16a74d39ac1a372311e94869a68ac3 Author: Caolán McNamara <[email protected]> AuthorDate: Thu Oct 7 11:56:29 2021 +0100 Commit: Adolfo Jayme Barrientos <[email protected]> CommitDate: Sat Oct 9 03:07:51 2021 +0200 fix "gtk_bin_remove: assertion 'priv->child == child' failed" warning on closing a document from tdf#141633 with a combobox in the tableform. So remove the mouse event widget before we remove the combobox replacement Change-Id: I95395ba60bb5fe7cf0b6e25176d0556c6bcc6611 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123212 Tested-by: Jenkins Reviewed-by: Adolfo Jayme Barrientos <[email protected]> diff --git a/vcl/unx/gtk3/gtkinst.cxx b/vcl/unx/gtk3/gtkinst.cxx index 66cefee6b559..727b6b547c36 100644 --- a/vcl/unx/gtk3/gtkinst.cxx +++ b/vcl/unx/gtk3/gtkinst.cxx @@ -2712,6 +2712,74 @@ protected: #endif } + void DisconnectMouseEvents() + { + if (m_nButtonPressSignalId) + { +#if GTK_CHECK_VERSION(4, 0, 0) + g_signal_handler_disconnect(get_click_controller(), m_nButtonPressSignalId); +#else + g_signal_handler_disconnect(m_pMouseEventBox, m_nButtonPressSignalId); +#endif + m_nButtonPressSignalId = 0; + } + if (m_nMotionSignalId) + { +#if GTK_CHECK_VERSION(4, 0, 0) + g_signal_handler_disconnect(get_motion_controller(), m_nMotionSignalId); +#else + g_signal_handler_disconnect(m_pMouseEventBox, m_nMotionSignalId); +#endif + m_nMotionSignalId = 0; + } + if (m_nLeaveSignalId) + { +#if GTK_CHECK_VERSION(4, 0, 0) + g_signal_handler_disconnect(get_motion_controller(), m_nLeaveSignalId); +#else + g_signal_handler_disconnect(m_pMouseEventBox, m_nLeaveSignalId); +#endif + m_nLeaveSignalId = 0; + } + if (m_nEnterSignalId) + { +#if GTK_CHECK_VERSION(4, 0, 0) + g_signal_handler_disconnect(get_motion_controller(), m_nEnterSignalId); +#else + g_signal_handler_disconnect(m_pMouseEventBox, m_nEnterSignalId); +#endif + m_nEnterSignalId = 0; + } + if (m_nButtonReleaseSignalId) + { +#if GTK_CHECK_VERSION(4, 0, 0) + g_signal_handler_disconnect(get_click_controller(), m_nButtonReleaseSignalId); +#else + g_signal_handler_disconnect(m_pMouseEventBox, m_nButtonReleaseSignalId); +#endif + m_nButtonReleaseSignalId = 0; + } + +#if !GTK_CHECK_VERSION(4, 0, 0) + if (m_pMouseEventBox && m_pMouseEventBox != m_pWidget) + { + // put things back they way we found them + GtkWidget* pParent = gtk_widget_get_parent(m_pMouseEventBox); + + g_object_ref(m_pWidget); + gtk_container_remove(GTK_CONTAINER(m_pMouseEventBox), m_pWidget); + + gtk_widget_destroy(m_pMouseEventBox); + + gtk_container_add(GTK_CONTAINER(pParent), m_pWidget); + // coverity[freed_arg : FALSE] - this does not free m_pWidget, it is reffed by pParent + g_object_unref(m_pWidget); + + m_pMouseEventBox = m_pWidget; + } +#endif + } + private: bool m_bTakeOwnership; #if !GTK_CHECK_VERSION(4, 0, 0) @@ -4016,46 +4084,6 @@ public: g_signal_handler_disconnect(m_pWidget, m_nKeyPressSignalId); if (m_nKeyReleaseSignalId) g_signal_handler_disconnect(m_pWidget, m_nKeyReleaseSignalId); - if (m_nButtonPressSignalId) - { -#if GTK_CHECK_VERSION(4, 0, 0) - g_signal_handler_disconnect(get_click_controller(), m_nButtonPressSignalId); -#else - g_signal_handler_disconnect(m_pMouseEventBox, m_nButtonPressSignalId); -#endif - } - if (m_nMotionSignalId) - { -#if GTK_CHECK_VERSION(4, 0, 0) - g_signal_handler_disconnect(get_motion_controller(), m_nMotionSignalId); -#else - g_signal_handler_disconnect(m_pMouseEventBox, m_nMotionSignalId); -#endif - } - if (m_nLeaveSignalId) - { -#if GTK_CHECK_VERSION(4, 0, 0) - g_signal_handler_disconnect(get_motion_controller(), m_nLeaveSignalId); -#else - g_signal_handler_disconnect(m_pMouseEventBox, m_nLeaveSignalId); -#endif - } - if (m_nEnterSignalId) - { -#if GTK_CHECK_VERSION(4, 0, 0) - g_signal_handler_disconnect(get_motion_controller(), m_nEnterSignalId); -#else - g_signal_handler_disconnect(m_pMouseEventBox, m_nEnterSignalId); -#endif - } - if (m_nButtonReleaseSignalId) - { -#if GTK_CHECK_VERSION(4, 0, 0) - g_signal_handler_disconnect(get_click_controller(), m_nButtonReleaseSignalId); -#else - g_signal_handler_disconnect(m_pMouseEventBox, m_nButtonReleaseSignalId); -#endif - } if (m_nFocusInSignalId) { @@ -4080,22 +4108,7 @@ public: do_set_background(COL_AUTO); -#if !GTK_CHECK_VERSION(4, 0, 0) - if (m_pMouseEventBox && m_pMouseEventBox != m_pWidget) - { - // put things back they way we found them - GtkWidget* pParent = gtk_widget_get_parent(m_pMouseEventBox); - - g_object_ref(m_pWidget); - gtk_container_remove(GTK_CONTAINER(m_pMouseEventBox), m_pWidget); - - gtk_widget_destroy(m_pMouseEventBox); - - gtk_container_add(GTK_CONTAINER(pParent), m_pWidget); - // coverity[freed_arg : FALSE] - this does not free m_pWidget, it is reffed by pParent - g_object_unref(m_pWidget); - } -#endif + DisconnectMouseEvents(); if (m_bTakeOwnership) { @@ -20751,6 +20764,8 @@ public: // restore original hierarchy in dtor so a new GtkInstanceComboBox will // result in the same layout each time { + DisconnectMouseEvents(); + g_object_ref(m_pComboBox); GtkContainer* pContainer = getContainer();
