diff options
author | Caolán McNamara <caolanm@redhat.com> | 2022-10-26 10:34:32 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2022-10-26 12:54:03 +0200 |
commit | bef36eed84bbc1663b174a082d0d3e6544aaab88 (patch) | |
tree | 54bae1d229d9e349e79487d6fdbf1b2ba6104520 /cui | |
parent | ad2310fec997c73e7546c27aa2aaf2dfd6dbbdf6 (diff) |
crashreporting: crash in thesaurus dialog PostUserEvent
not reproducible, but a common error to post an event that
outlives the owner
Change-Id: Ic2633c504d853116d03e3322f552ae66e7e7e14e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141869
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'cui')
-rw-r--r-- | cui/source/dialogs/thesdlg.cxx | 14 | ||||
-rw-r--r-- | cui/source/inc/thesdlg.hxx | 3 |
2 files changed, 14 insertions, 3 deletions
diff --git a/cui/source/dialogs/thesdlg.cxx b/cui/source/dialogs/thesdlg.cxx index a9f4883f4c70..1d98480973ee 100644 --- a/cui/source/dialogs/thesdlg.cxx +++ b/cui/source/dialogs/thesdlg.cxx @@ -165,8 +165,8 @@ void SvxThesaurusDialog::LookUp_Impl() m_xAlternativesCT->set_visible(m_bWordFound); m_xNotFound->set_visible(!m_bWordFound); - if (m_bWordFound) - Application::PostUserEvent(LINK(this, SvxThesaurusDialog, SelectFirstHdl_Impl)); + if (m_bWordFound && !m_nSelectFirstEvent) + m_nSelectFirstEvent = Application::PostUserEvent(LINK(this, SvxThesaurusDialog, SelectFirstHdl_Impl)); if (m_xWordCB->find_text(aText) == -1) m_xWordCB->append_text(aText); @@ -217,13 +217,15 @@ IMPL_LINK( SvxThesaurusDialog, AlternativesDoubleClickHdl_Impl, weld::TreeView&, //! workaround to set the selection since calling SelectEntryPos within //! the double click handler does not work - Application::PostUserEvent(LINK(this, SvxThesaurusDialog, SelectFirstHdl_Impl)); + if (!m_nSelectFirstEvent) + m_nSelectFirstEvent = Application::PostUserEvent(LINK(this, SvxThesaurusDialog, SelectFirstHdl_Impl)); return true; } IMPL_LINK_NOARG(SvxThesaurusDialog, SelectFirstHdl_Impl, void *, void) { + m_nSelectFirstEvent = nullptr; if (m_xAlternativesCT->n_children() >= 2) { m_xAlternativesCT->select(1); // pos 0 is a 'header' that is not selectable @@ -249,6 +251,7 @@ SvxThesaurusDialog::SvxThesaurusDialog( , m_xReplaceEdit(m_xBuilder->weld_entry("replaceed")) , m_xLangLB(m_xBuilder->weld_combo_box("langcb")) , m_xReplaceBtn(m_xBuilder->weld_button("ok")) + , m_nSelectFirstEvent(nullptr) { m_aModifyIdle.SetInvokeHandler( LINK( this, SvxThesaurusDialog, ModifyTimer_Hdl ) ); m_aModifyIdle.SetPriority( TaskPriority::LOWEST ); @@ -316,6 +319,11 @@ SvxThesaurusDialog::SvxThesaurusDialog( SvxThesaurusDialog::~SvxThesaurusDialog() { + if (m_nSelectFirstEvent) + { + Application::RemoveUserEvent(m_nSelectFirstEvent); + m_nSelectFirstEvent = nullptr; + } } IMPL_LINK_NOARG(SvxThesaurusDialog, ReplaceBtnHdl_Impl, weld::Button&, void) diff --git a/cui/source/inc/thesdlg.hxx b/cui/source/inc/thesdlg.hxx index de085d678682..05865d68d92f 100644 --- a/cui/source/inc/thesdlg.hxx +++ b/cui/source/inc/thesdlg.hxx @@ -26,6 +26,8 @@ #include <memory> #include <stack> +struct ImplSVEvent; + class SvxThesaurusDialog : public SfxDialogController { Idle m_aModifyIdle; @@ -43,6 +45,7 @@ class SvxThesaurusDialog : public SfxDialogController std::unique_ptr<weld::Entry> m_xReplaceEdit; std::unique_ptr<weld::ComboBox> m_xLangLB; std::unique_ptr<weld::Button> m_xReplaceBtn; + ImplSVEvent* m_nSelectFirstEvent; public: virtual ~SvxThesaurusDialog() override; |