diff options
author | Michael Stahl <mstahl@redhat.com> | 2014-05-19 22:03:18 +0200 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2014-05-20 06:57:57 -0500 |
commit | 2fd89dd60366caa64ed8b31b588e72dd639104bd (patch) | |
tree | d069b606724f3fcf28e3b2b48f9b81a0b7c96a92 | |
parent | 164e10869f91b75db03b09f53e1467098b3e6b93 (diff) |
fdo#78536: sfx2: template dialog: make the am-i-dead-yet check reentrant
In the fine tradition of our enterprise-grade code base, this lets the
check in SfxCommonTemplateDialog_Impl::Execute_Impl() do an early
return if the "this" instance has signalled its untimely demise even if
there are multiple calls of Execute_Impl() on the stack; extending
the scheme with further epicycles to make it work if the Execute_Impl()
calls happen on 2 different threads is left as an exercise for the
interested reader.
(regression from bcc52fb2ebdf77a1cc089857775fd742085b45b6)
(cherry picked from commit 838c580fdba8b1c72bc854d101d302be0e3861d5)
Conflicts:
sfx2/source/dialog/templdlg.cxx
Change-Id: I1d9f0d82bf6d9f5da8f9bd2be57d01937d71fd26
Reviewed-on: https://gerrit.libreoffice.org/9406
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | sfx2/source/dialog/templdlg.cxx | 13 | ||||
-rw-r--r-- | sfx2/source/inc/templdgi.hxx | 2 |
2 files changed, 11 insertions, 4 deletions
diff --git a/sfx2/source/dialog/templdlg.cxx b/sfx2/source/dialog/templdlg.cxx index cbd856ff617a..11b430cddaf2 100644 --- a/sfx2/source/dialog/templdlg.cxx +++ b/sfx2/source/dialog/templdlg.cxx @@ -100,20 +100,22 @@ class SfxCommonTemplateDialog_Impl::DeletionWatcher : private boost::noncopyable public: explicit DeletionWatcher(SfxCommonTemplateDialog_Impl& rDialog) : m_pDialog(&rDialog) + , m_pPrevious(m_pDialog->impl_setDeletionWatcher(this)) { - m_pDialog->impl_setDeletionWatcher(this); } ~DeletionWatcher() { if (m_pDialog) - m_pDialog->impl_setDeletionWatcher(0); + m_pDialog->impl_setDeletionWatcher(m_pPrevious); } // Signal that the dialog was deleted void signal() { m_pDialog = 0; + if (m_pPrevious) + m_pPrevious->signal(); } // Return true if the dialog was deleted @@ -124,6 +126,7 @@ public: private: SfxCommonTemplateDialog_Impl* m_pDialog; + DeletionWatcher *const m_pPrevious; /// let's add more epicycles! }; // Re-direct functions @@ -1015,9 +1018,13 @@ void SfxCommonTemplateDialog_Impl::impl_clear() DELETEZ( m_pStyleFamiliesId ); } -void SfxCommonTemplateDialog_Impl::impl_setDeletionWatcher(DeletionWatcher* pNewWatcher) +SfxCommonTemplateDialog_Impl::DeletionWatcher * +SfxCommonTemplateDialog_Impl::impl_setDeletionWatcher( + DeletionWatcher *const pNewWatcher) { + DeletionWatcher *const pRet(m_pDeletionWatcher); m_pDeletionWatcher = pNewWatcher; + return pRet; } //------------------------------------------------------------------------- diff --git a/sfx2/source/inc/templdgi.hxx b/sfx2/source/inc/templdgi.hxx index 0011aed2796c..844acdb79eb0 100644 --- a/sfx2/source/inc/templdgi.hxx +++ b/sfx2/source/inc/templdgi.hxx @@ -111,7 +111,7 @@ private: void ReadResource(); void ClearResource(); void impl_clear(); - void impl_setDeletionWatcher(DeletionWatcher* pNewWatcher); + DeletionWatcher * impl_setDeletionWatcher(DeletionWatcher* pNewWatcher); protected: #define MAX_FAMILIES 5 |