summaryrefslogtreecommitdiff
path: root/fpicker/source/unx
diff options
context:
space:
mode:
authorJan Holesovsky <kendy@suse.cz>2010-08-25 17:57:55 +0200
committerJan Holesovsky <kendy@suse.cz>2010-08-26 12:54:55 +0200
commit47c333a0f61a5d91c1379f4b6aac58e5505735d4 (patch)
tree35248ee6b4a399aa858765668f2cebc19757c399 /fpicker/source/unx
parentb019dff1003b031e7050e119133f015f25d08b4d (diff)
fpicker-kde-less-threads.diff: Update KDE3 fpicker after the threads change.
Introduced in i#93366 - n#427336.
Diffstat (limited to 'fpicker/source/unx')
-rw-r--r--fpicker/source/unx/kde_unx/UnxCommandThread.hxx44
-rw-r--r--fpicker/source/unx/kde_unx/UnxFilePicker.cxx8
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 14e8d3ab96..db6b2c2af2 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 0ae7c4dfd4..d4028bf427 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();
}