summaryrefslogtreecommitdiff
path: root/fpicker
diff options
context:
space:
mode:
authorTino Rachui <tra@openoffice.org>2002-03-21 06:35:14 +0000
committerTino Rachui <tra@openoffice.org>2002-03-21 06:35:14 +0000
commit6ec78fb18144e24a7483b4676a41024473c31cf1 (patch)
tree11dca8bc813d6c5fbaeabdec1893624af933f373 /fpicker
parent329f11775f3febe663a4d259e59325386930bbe6 (diff)
#96112#changed start/stop logic
Diffstat (limited to 'fpicker')
-rw-r--r--fpicker/source/win32/filepicker/asynceventnotifier.cxx27
-rw-r--r--fpicker/source/win32/filepicker/asynceventnotifier.hxx41
2 files changed, 33 insertions, 35 deletions
diff --git a/fpicker/source/win32/filepicker/asynceventnotifier.cxx b/fpicker/source/win32/filepicker/asynceventnotifier.cxx
index cce1a1d47ac7..222e7cc689e4 100644
--- a/fpicker/source/win32/filepicker/asynceventnotifier.cxx
+++ b/fpicker/source/win32/filepicker/asynceventnotifier.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: asynceventnotifier.cxx,v $
*
- * $Revision: 1.7 $
+ * $Revision: 1.8 $
*
- * last change: $Author: tra $ $Date: 2002-02-22 09:58:44 $
+ * last change: $Author: tra $ $Date: 2002-03-21 07:35:14 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -81,6 +81,7 @@
#include <process.h>
#include <windows.h>
+#include <memory>
//------------------------------------------------
//
@@ -143,7 +144,7 @@ void SAL_CALL CAsyncEventNotifier::stop()
{
OSL_PRECOND(GetCurrentThreadId() != m_ThreadId, "Method called in wrong thread context!");
- ClearableMutexGuard aGuard(m_Mutex);
+ ResettableMutexGuard aGuard(m_Mutex);
OSL_PRECOND(m_bRun,"Event notifier does not run!");
@@ -163,8 +164,7 @@ void SAL_CALL CAsyncEventNotifier::stop()
// lock mutex again to reset m_hThread
// and prevent a race with start()
-
- MutexGuard anotherGuard(m_Mutex);
+ aGuard.reset();
CloseHandle(m_hThread);
m_hThread = 0;
@@ -174,7 +174,7 @@ void SAL_CALL CAsyncEventNotifier::stop()
//
//------------------------------------------------
-void SAL_CALL CAsyncEventNotifier::notifyEvent(EventListenerMethod_t aListenerMethod, FilePickerEvent aEvent)
+void SAL_CALL CAsyncEventNotifier::notifyEvent(CEventNotification* EventNotification)
{
MutexGuard aGuard(m_Mutex);
@@ -182,7 +182,7 @@ void SAL_CALL CAsyncEventNotifier::notifyEvent(EventListenerMethod_t aListenerMe
if (m_bRun)
{
- m_EventList.push_back(std::make_pair(aListenerMethod, aEvent));
+ m_EventList.push_back(EventNotification);
m_NotifyEvent.set();
}
}
@@ -212,7 +212,7 @@ void SAL_CALL CAsyncEventNotifier::resetNotifyEvent()
//
//------------------------------------------------
-CAsyncEventNotifier::EventRecord_t SAL_CALL CAsyncEventNotifier::getNextEventRecord()
+CEventNotification* SAL_CALL CAsyncEventNotifier::getNextEventRecord()
{
MutexGuard aGuard(m_Mutex);
return m_EventList.front();
@@ -236,13 +236,13 @@ void SAL_CALL CAsyncEventNotifier::run()
{
while (m_bRun)
{
- m_NotifyEvent.wait( );
+ m_NotifyEvent.wait();
if (m_bRun)
{
while (getEventListSize() > 0)
{
- EventRecord_t aEventRecord = getNextEventRecord();
+ std::auto_ptr<CEventNotification> EventNotification(getNextEventRecord());
removeNextEventRecord();
::cppu::OInterfaceContainerHelper* pICHelper =
@@ -254,16 +254,13 @@ void SAL_CALL CAsyncEventNotifier::run()
while(iter.hasMoreElements())
{
- Reference<XFilePickerListener> xFPListener(iter.next(), UNO_QUERY);
-
try
{
- if (xFPListener.is())
- (xFPListener.get()->*aEventRecord.first)(aEventRecord.second);
+ EventNotification->notifyEventListener(iter.next());
}
catch(RuntimeException&)
{
- OSL_ENSURE(sal_False, "RuntimeException during event dispatching");
+ OSL_ENSURE(sal_False,"RuntimeException during event dispatching");
}
}
}
diff --git a/fpicker/source/win32/filepicker/asynceventnotifier.hxx b/fpicker/source/win32/filepicker/asynceventnotifier.hxx
index b64887c7ba5f..aa40b5f5fdf8 100644
--- a/fpicker/source/win32/filepicker/asynceventnotifier.hxx
+++ b/fpicker/source/win32/filepicker/asynceventnotifier.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: asynceventnotifier.hxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: tra $ $Date: 2002-02-22 09:58:44 $
+ * last change: $Author: tra $ $Date: 2002-03-21 07:35:14 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -87,6 +87,10 @@
#include <list>
#include <utility>
+#ifndef _EVENTNOTIFICATION_HXX_
+#include "eventnotification.hxx"
+#endif
+
//---------------------------------------------
//
//---------------------------------------------
@@ -94,36 +98,33 @@
class CAsyncEventNotifier
{
public:
- typedef void (SAL_CALL ::com::sun::star::ui::dialogs::XFilePickerListener::*EventListenerMethod_t)(const ::com::sun::star::ui::dialogs::FilePickerEvent&);
-
-public:
CAsyncEventNotifier(cppu::OBroadcastHelper& rBroadcastHelper);
bool SAL_CALL start();
void SAL_CALL stop();
- void SAL_CALL notifyEvent( EventListenerMethod_t aListenerMethod, ::com::sun::star::ui::dialogs::FilePickerEvent aEvent );
+ // this class is responsible for the memory management of
+ // the CEventNotification instance
+ void SAL_CALL notifyEvent(CEventNotification* EventNotification);
private:
- typedef std::pair<EventListenerMethod_t, ::com::sun::star::ui::dialogs::FilePickerEvent> EventRecord_t;
-
- size_t SAL_CALL getEventListSize();
- void SAL_CALL resetNotifyEvent();
- EventRecord_t SAL_CALL getNextEventRecord();
- void SAL_CALL removeNextEventRecord();
+ size_t SAL_CALL getEventListSize();
+ void SAL_CALL resetNotifyEvent();
+ CEventNotification* SAL_CALL getNextEventRecord();
+ void SAL_CALL removeNextEventRecord();
void SAL_CALL run( );
- static unsigned int WINAPI ThreadProc( LPVOID pParam );
+ static unsigned int WINAPI ThreadProc(LPVOID pParam);
private:
- std::list<EventRecord_t> m_EventList;
- HANDLE m_hThread;
- bool m_bRun;
- unsigned m_ThreadId;
- ::cppu::OBroadcastHelper& m_rBroadcastHelper;
- osl::Condition m_NotifyEvent;
- osl::Mutex m_Mutex;
+ std::list<CEventNotification*> m_EventList;
+ HANDLE m_hThread;
+ bool m_bRun;
+ unsigned m_ThreadId;
+ ::cppu::OBroadcastHelper& m_rBroadcastHelper;
+ osl::Condition m_NotifyEvent;
+ osl::Mutex m_Mutex;
// prevent copy and assignment
private: