Kaydet (Commit) 6c3eff7e authored tarafından Jan Holesovsky's avatar Jan Holesovsky

fpicker-kde-less-threads.diff: Update KDE3 fpicker after the threads change.

Introduced in i#93366 - n#427336.
üst bf8b9c0e
...@@ -36,10 +36,50 @@ ...@@ -36,10 +36,50 @@
#include <osl/thread.hxx> #include <osl/thread.hxx>
#include <rtl/ustring.hxx> #include <rtl/ustring.hxx>
#include <vcl/svapp.hxx>
#include <list> #include <list>
class UnxFilePickerNotifyThread; 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 class UnxFilePickerCommandThread : public ::osl::Thread
{ {
protected: protected:
...@@ -48,7 +88,7 @@ protected: ...@@ -48,7 +88,7 @@ protected:
::osl::Mutex m_aMutex; ::osl::Mutex m_aMutex;
::osl::Condition m_aExecCondition; YieldingCondition m_aExecCondition;
sal_Bool m_aResult; sal_Bool m_aResult;
::osl::Condition m_aGetCurrentFilterCondition; ::osl::Condition m_aGetCurrentFilterCondition;
...@@ -67,7 +107,7 @@ public: ...@@ -67,7 +107,7 @@ public:
UnxFilePickerCommandThread( UnxFilePickerNotifyThread *pNotifyThread, int nReadFD ); UnxFilePickerCommandThread( UnxFilePickerNotifyThread *pNotifyThread, int nReadFD );
~UnxFilePickerCommandThread(); ~UnxFilePickerCommandThread();
::osl::Condition& SAL_CALL execCondition() { return m_aExecCondition; } YieldingCondition& SAL_CALL execCondition() { return m_aExecCondition; }
sal_Bool SAL_CALL result(); sal_Bool SAL_CALL result();
::osl::Condition& SAL_CALL getCurrentFilterCondition() { return m_aGetCurrentFilterCondition; } ::osl::Condition& SAL_CALL getCurrentFilterCondition() { return m_aGetCurrentFilterCondition; }
......
...@@ -178,8 +178,12 @@ sal_Int16 SAL_CALL UnxFilePicker::execute() ...@@ -178,8 +178,12 @@ sal_Int16 SAL_CALL UnxFilePicker::execute()
{ {
checkFilePicker(); checkFilePicker();
sendCommand( ::rtl::OUString::createFromAscii( "exec" ), // this is _not_ an osl::Condition, see i#93366
m_pCommandThread->execCondition() ); m_pCommandThread->execCondition().reset();
sendCommand( ::rtl::OUString::createFromAscii( "exec" ) );
m_pCommandThread->execCondition().wait();
return m_pCommandThread->result(); return m_pCommandThread->result();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment