diff options
-rw-r--r-- | fpicker/source/unx/kde_unx/UnxCommandThread.hxx | 44 | ||||
-rw-r--r-- | fpicker/source/unx/kde_unx/UnxFilePicker.cxx | 8 |
2 files changed, 48 insertions, 4 deletions
diff --git a/fpicker/source/unx/kde_unx/UnxCommandThread.hxx b/fpicker/source/unx/kde_unx/UnxCommandThread.hxx index 14e8d3ab9629..db6b2c2af20f 100644 --- a/fpicker/source/unx/kde_unx/UnxCommandThread.hxx +++ b/fpicker/source/unx/kde_unx/UnxCommandThread.hxx @@ -36,10 +36,50 @@ #include <osl/thread.hxx> #include <rtl/ustring.hxx> +#include <vcl/svapp.hxx> + #include <list> class UnxFilePickerNotifyThread; +/** Synchronization for the 'thread-less' version of the fpicker. + + Something like osl::Condition, but calls Application::Yield() while in + wait(). +*/ +class YieldingCondition +{ + ::osl::Mutex m_aMutex; + bool m_bValue; + + bool get() + { + ::osl::MutexGuard aGuard( m_aMutex ); + return m_bValue; + } + +public: + YieldingCondition() { reset(); } + + void reset() + { + ::osl::MutexGuard aGuard( m_aMutex ); + m_bValue = false; + } + + void set() + { + ::osl::MutexGuard aGuard( m_aMutex ); + m_bValue = true; + } + + void wait() + { + while ( !get() ) + Application::Yield(); + } +}; + class UnxFilePickerCommandThread : public ::osl::Thread { protected: @@ -48,7 +88,7 @@ protected: ::osl::Mutex m_aMutex; - ::osl::Condition m_aExecCondition; + YieldingCondition m_aExecCondition; sal_Bool m_aResult; ::osl::Condition m_aGetCurrentFilterCondition; @@ -67,7 +107,7 @@ public: UnxFilePickerCommandThread( UnxFilePickerNotifyThread *pNotifyThread, int nReadFD ); ~UnxFilePickerCommandThread(); - ::osl::Condition& SAL_CALL execCondition() { return m_aExecCondition; } + YieldingCondition& SAL_CALL execCondition() { return m_aExecCondition; } sal_Bool SAL_CALL result(); ::osl::Condition& SAL_CALL getCurrentFilterCondition() { return m_aGetCurrentFilterCondition; } diff --git a/fpicker/source/unx/kde_unx/UnxFilePicker.cxx b/fpicker/source/unx/kde_unx/UnxFilePicker.cxx index 0ae7c4dfd480..d4028bf42749 100644 --- a/fpicker/source/unx/kde_unx/UnxFilePicker.cxx +++ b/fpicker/source/unx/kde_unx/UnxFilePicker.cxx @@ -178,8 +178,12 @@ sal_Int16 SAL_CALL UnxFilePicker::execute() { checkFilePicker(); - sendCommand( ::rtl::OUString::createFromAscii( "exec" ), - m_pCommandThread->execCondition() ); + // this is _not_ an osl::Condition, see i#93366 + m_pCommandThread->execCondition().reset(); + + sendCommand( ::rtl::OUString::createFromAscii( "exec" ) ); + + m_pCommandThread->execCondition().wait(); return m_pCommandThread->result(); } |