summaryrefslogtreecommitdiff
path: root/fpicker
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
commit6c3eff7ee952ad4da79082b52a2eaf288a6a262b (patch)
tree72050e8fd20eb271e85a917fa230504f6746adac /fpicker
parentbf8b9c0e428f44a25c10c19e248215c2d767d426 (diff)
fpicker-kde-less-threads.diff: Update KDE3 fpicker after the threads change.
Introduced in i#93366 - n#427336.
Diffstat (limited to 'fpicker')
-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 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();
}