From 8cd21316bafbcf70f4c5cef3a173e639e9bdcd66 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Mon, 8 Aug 2011 11:45:24 +0100 Subject: complete and utter nonsense Taking the address of the pCheck argument in LoadEnvListener ctor gives the address of the temporary on the stack/register itself, not the address of LoadEnv's m_pCheck which is apparently what it thinks it's doing. All that can be said about m_ppCheck is deferencing it inside the ctor will give the value of pCheck for the duration of the ctor. What happens later on in subsequent method calls is pot luck, storing it and deferencing it later is meaningless. Presumably this worked because it's rare for the dereferenced m_ppCheck to end up containing 0 at the wrong time. Right now in a debugging build the mail merge dialog from print... when there are form fields in a document and "print form field" is selected triggers a 0 in there post construction at some stage or other, causing the dialog to never appear as the loading here never completes. --- framework/source/loadenv/loadenv.cxx | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-) (limited to 'framework/source/loadenv') diff --git a/framework/source/loadenv/loadenv.cxx b/framework/source/loadenv/loadenv.cxx index 784f6f765d27..a746211da472 100644 --- a/framework/source/loadenv/loadenv.cxx +++ b/framework/source/loadenv/loadenv.cxx @@ -117,17 +117,16 @@ class LoadEnvListener : private ThreadHelpBase { private: - void** m_ppCheck ; + bool m_bWaitingResult; LoadEnv* m_pLoadEnv; public: //_______________________________________ - LoadEnvListener(void* pCheck , - LoadEnv* pLoadEnv) + LoadEnvListener(LoadEnv* pLoadEnv) + : m_bWaitingResult(true) + , m_pLoadEnv(pLoadEnv) { - m_ppCheck = &pCheck ; - m_pLoadEnv = pLoadEnv; } //_______________________________________ @@ -154,7 +153,6 @@ LoadEnv::LoadEnv(const css::uno::Reference< css::lang::XMultiServiceFactory >& x throw(LoadEnvException, css::uno::RuntimeException) : ThreadHelpBase( ) , m_xSMGR (xSMGR) - , m_pCheck (this ) , m_pQuietInteraction( 0 ) { } @@ -162,7 +160,6 @@ LoadEnv::LoadEnv(const css::uno::Reference< css::lang::XMultiServiceFactory >& x LoadEnv::~LoadEnv() { - m_pCheck = 0; } @@ -537,9 +534,9 @@ void SAL_CALL LoadEnvListener::loadFinished(const css::uno::Reference< css::fram // SAFE -> ---------------------------------- WriteGuard aWriteLock(m_aLock); - if (m_ppCheck && *m_ppCheck) + if (m_bWaitingResult) m_pLoadEnv->impl_setResult(sal_True); - m_ppCheck = NULL; + m_bWaitingResult = false; aWriteLock.unlock(); // <- SAFE ---------------------------------- @@ -552,9 +549,9 @@ void SAL_CALL LoadEnvListener::loadCancelled(const css::uno::Reference< css::fra // SAFE -> ---------------------------------- WriteGuard aWriteLock(m_aLock); - if (m_ppCheck && *m_ppCheck) + if (m_bWaitingResult) m_pLoadEnv->impl_setResult(sal_False); - m_ppCheck = NULL; + m_bWaitingResult = false; aWriteLock.unlock(); // <- SAFE ---------------------------------- @@ -567,7 +564,7 @@ void SAL_CALL LoadEnvListener::dispatchFinished(const css::frame::DispatchResult // SAFE -> ---------------------------------- WriteGuard aWriteLock(m_aLock); - if (!m_ppCheck || !*m_ppCheck) + if (!m_bWaitingResult) return; switch(aEvent.State) @@ -584,7 +581,7 @@ void SAL_CALL LoadEnvListener::dispatchFinished(const css::frame::DispatchResult m_pLoadEnv->impl_setResult(sal_False); break; } - m_ppCheck = NULL; + m_bWaitingResult = false; aWriteLock.unlock(); // <- SAFE ---------------------------------- @@ -597,9 +594,9 @@ void SAL_CALL LoadEnvListener::disposing(const css::lang::EventObject&) // SAFE -> ---------------------------------- WriteGuard aWriteLock(m_aLock); - if (m_ppCheck && *m_ppCheck) + if (m_bWaitingResult) m_pLoadEnv->impl_setResult(sal_False); - m_ppCheck = NULL; + m_bWaitingResult = false; aWriteLock.unlock(); // <- SAFE ---------------------------------- @@ -928,8 +925,7 @@ sal_Bool LoadEnv::impl_handleContent() // SAFE -> ----------------------------------- WriteGuard aWriteLock(m_aLock); m_xAsynchronousJob = xHandler; - m_pCheck = this; - LoadEnvListener* pListener = new LoadEnvListener(m_pCheck, this); + LoadEnvListener* pListener = new LoadEnvListener(this); aWriteLock.unlock(); // <- SAFE ----------------------------------- @@ -1136,8 +1132,7 @@ sal_Bool LoadEnv::impl_loadContent() // SAFE -> ----------------------------------- aWriteLock.lock(); m_xAsynchronousJob = xAsyncLoader; - m_pCheck = this; - LoadEnvListener* pListener = new LoadEnvListener(m_pCheck, this); + LoadEnvListener* pListener = new LoadEnvListener(this); aWriteLock.unlock(); // <- SAFE ----------------------------------- -- cgit