Browse Source

Merge pull request #12579 from de1acr0ix/fix-mainloop-cancellation-hang

Fix UI thread main loop cancellation from another thread on macOS
pull/12593/head
Max Katz 3 years ago
committed by GitHub
parent
commit
0b6294ecee
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 29
      native/Avalonia.Native/src/OSX/platformthreading.mm

29
native/Avalonia.Native/src/OSX/platformthreading.mm

@ -17,7 +17,6 @@ public:
Cancelled = true;
if(Running)
{
Running = false;
if(![NSThread isMainThread])
{
AddRef();
@ -28,22 +27,22 @@ public:
});
return;
};
Running = false;
if(IsApp)
[NSApp stop:nil];
else
{
// Wakeup the event loop
NSEvent* event = [NSEvent otherEventWithType:NSEventTypeApplicationDefined
location:NSMakePoint(0, 0)
modifierFlags:0
timestamp:0
windowNumber:0
context:nil
subtype:0
data1:0
data2:0];
[NSApp postEvent:event atStart:YES];
}
// Wakeup the event loop
NSEvent* event = [NSEvent otherEventWithType:NSEventTypeApplicationDefined
location:NSMakePoint(0, 0)
modifierFlags:0
timestamp:0
windowNumber:0
context:nil
subtype:0
data1:0
data2:0];
[NSApp postEvent:event atStart:YES];
}
};
};

Loading…
Cancel
Save