diff options
Diffstat (limited to 'fpicker')
-rw-r--r-- | fpicker/source/win32/folderpicker/MtaFop.cxx | 122 |
1 files changed, 44 insertions, 78 deletions
diff --git a/fpicker/source/win32/folderpicker/MtaFop.cxx b/fpicker/source/win32/folderpicker/MtaFop.cxx index 6f8af44c358a..ba951039edeb 100644 --- a/fpicker/source/win32/folderpicker/MtaFop.cxx +++ b/fpicker/source/win32/folderpicker/MtaFop.cxx @@ -20,6 +20,7 @@ #include <osl/diagnose.h> #include <osl/thread.h> #include <o3tl/char16_t2wchar_t.hxx> +#include <vcl/svapp.hxx> #include "MtaFop.hxx" #include <wchar.h> @@ -70,23 +71,6 @@ namespace OSL_ASSERT( aRequestContext && aRequestContext->hEvent ); CloseHandle( aRequestContext->hEvent ); } - - - // Determine if current thread is - // an MTA or STA thread - - bool IsMTA() - { - HRESULT hr = CoInitialize(nullptr); - - if (RPC_E_CHANGED_MODE == hr) - return true; - - if(SUCCEEDED(hr)) - CoUninitialize(); - - return false; - } } @@ -224,80 +208,62 @@ bool CMtaFolderPicker::browseForFolder( ) { bool bRet = false; - if (IsMTA()) - { + OSL_ASSERT( m_hEvtThrdReady ); - OSL_ASSERT( m_hEvtThrdReady ); + if ( WaitForSingleObject( m_hEvtThrdReady, MAX_WAITTIME ) != WAIT_OBJECT_0 ) + { + OSL_FAIL( "sta thread not ready" ); + return false; + } - if ( WaitForSingleObject( m_hEvtThrdReady, MAX_WAITTIME ) != WAIT_OBJECT_0 ) - { - OSL_FAIL( "sta thread not ready" ); - return false; - } + RequestContext aReqCtx; - RequestContext aReqCtx; + if ( !InitializeRequestContext( &aReqCtx ) ) + { + OSL_ASSERT( false ); + return false; + } - if ( !InitializeRequestContext( &aReqCtx ) ) - { - OSL_ASSERT( false ); - return false; - } + // marshall request into the sta thread + BOOL const ret = PostMessageW( + m_hwndStaRequestWnd, + MSG_BROWSEFORFOLDER, + 0, + reinterpret_cast< LPARAM >( &aReqCtx ) ); + SAL_WARN_IF(0 == ret, "fpicker", "ERROR: PostMessage() failed!"); - // marshall request into the sta thread - BOOL const ret = PostMessageW( - m_hwndStaRequestWnd, - MSG_BROWSEFORFOLDER, - 0, - reinterpret_cast< LPARAM >( &aReqCtx ) ); - SAL_WARN_IF(0 == ret, "fpicker", "ERROR: PostMessage() failed!"); + // waiting for the event to be signaled or + // window messages so that we don't block + // our parent window - // waiting for the event to be signaled or - // window messages so that we don't block - // our parent window + bool bContinue = true; - bool bContinue = true; + while ( bContinue ) + { + DWORD dwResult = MsgWaitForMultipleObjects( + 1, &aReqCtx.hEvent, false, INFINITE, QS_ALLEVENTS ); - while ( bContinue ) + switch ( dwResult ) { - DWORD dwResult = MsgWaitForMultipleObjects( - 1, &aReqCtx.hEvent, false, INFINITE, QS_ALLEVENTS ); + // the request context event is signaled + case WAIT_OBJECT_0: + bContinue = false; + break; - switch ( dwResult ) - { - // the request context event is signaled - case WAIT_OBJECT_0: - bContinue = false; - break; - - // a window message has arrived - case WAIT_OBJECT_0 + 1: - { - // dispatching all messages but we expect to - // receive only paint or timer messages that's - // why we don't need to call TranslateMessage or - // TranslateAccelerator, because keyboard or - // mouse messages are for the FolderPicker which - // is in the foreground and should not arrive here - MSG msg; - while ( PeekMessageW( &msg, nullptr, 0, 0, PM_REMOVE ) ) - DispatchMessageW(&msg); - } - break; - - // should not happen - default: - OSL_ASSERT( false ); - } - } + // a window message has arrived + case WAIT_OBJECT_0 + 1: + Application::Reschedule( true ); + break; - /*sal_Bool*/ bRet = aReqCtx.bRet; - DeinitializeRequestContext( &aReqCtx ); - } - else - { - bRet = onBrowseForFolder(); + // should not happen + default: + OSL_ASSERT( false ); + } } + /*sal_Bool*/ bRet = aReqCtx.bRet; + DeinitializeRequestContext( &aReqCtx ); + return bRet; } |