summaryrefslogtreecommitdiff
path: root/vcl/osx/salnstimer.mm
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/osx/salnstimer.mm
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/osx/salnstimer.mm')
-rw-r--r--vcl/osx/salnstimer.mm17
1 files changed, 3 insertions, 14 deletions
diff --git a/vcl/osx/salnstimer.mm b/vcl/osx/salnstimer.mm
index 9c3264295d60..c9867cf7a79e 100644
--- a/vcl/osx/salnstimer.mm
+++ b/vcl/osx/salnstimer.mm
@@ -26,24 +26,13 @@
#include "svdata.hxx"
@implementation TimerCallbackCaller
+
-(void)timerElapsed:(NSTimer*)pTimer
{
(void)pTimer;
-SAL_WNODEPRECATED_DECLARATIONS_PUSH
-// 'NSApplicationDefined' is deprecated: first deprecated in macOS 10.12
- NSEvent* pEvent = [NSEvent otherEventWithType: NSApplicationDefined
-SAL_WNODEPRECATED_DECLARATIONS_POP
- location: NSZeroPoint
- modifierFlags: 0
- timestamp: [NSDate timeIntervalSinceReferenceDate]
- windowNumber: 0
- context: nil
- subtype: AquaSalInstance::DispatchTimerEvent
- data1: 0
- data2: 0 ];
- assert( pEvent );
- [NSApp postEvent: pEvent atStart: YES];
+ ImplNSAppPostEvent( AquaSalInstance::DispatchTimerEvent, YES );
}
+
@end
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */