summaryrefslogtreecommitdiff
path: root/vcl/inc/osx
diff options
context:
space:
mode:
authorJan-Marek Glogowski <glogow@fbihome.de>2017-03-21 13:32:47 +0100
committerJan-Marek Glogowski <glogow@fbihome.de>2017-07-13 12:10:27 +0200
commit272026d70129603e1824b802a2a6920adcd09dc0 (patch)
treebcc3db683252eee20a977f961adcbecce351f180 /vcl/inc/osx
parentf0aabfe601223cee214b0be1b2ebf51a80b68f2c (diff)
OSX fix empty message queue handling
For some (unknown) reason [NSApp postEvent: ... atStart: NO] doesn't append the event, if the message queue is empty (AKA [NSApp nextEventMatchingMask .. ] returns nil). Due to nextEventMatchingMask usage, these postEvents have to run in the main thread. Using performSelectorOnMainThread deadlocks, since the calling thread may have locked the Yield mutex, so we simply defer the call using an NSEvent, like the Windows backend. So we have to peek at the queue and if it's empty simply prepend the event using [.. atStart: YES]. In the end this make the vcl_timer unit test pass on OSX. Change-Id: Ib41186425b2f76faa0e9f116f47fdcd60d878099
Diffstat (limited to 'vcl/inc/osx')
-rw-r--r--vcl/inc/osx/saltimer.h18
1 files changed, 16 insertions, 2 deletions
diff --git a/vcl/inc/osx/saltimer.h b/vcl/inc/osx/saltimer.h
index f9a6acb7a02f..86964115d648 100644
--- a/vcl/inc/osx/saltimer.h
+++ b/vcl/inc/osx/saltimer.h
@@ -26,10 +26,24 @@
#include "saltimer.hxx"
-class AquaSalTimer : public SalTimer
+/**
+ * if NO == bAtStart, then it has to be run in the main thread,
+ * e.g. via performSelectorOnMainThread!
+ **/
+void ImplNSAppPostEvent( short nEventId, BOOL bAtStart, int nUserData = 0 );
+
+class ReleasePoolHolder
{
- public:
+ NSAutoreleasePool* mpPool;
+
+public:
+ ReleasePoolHolder() : mpPool( [[NSAutoreleasePool alloc] init] ) {}
+ ~ReleasePoolHolder() { [mpPool release]; }
+};
+class AquaSalTimer : public SalTimer
+{
+public:
AquaSalTimer();
virtual ~AquaSalTimer() override;