Skip to content

Commit

Permalink
Fix main loop cancellation from another thread
Browse files Browse the repository at this point in the history
  • Loading branch information
de1acr0ix committed Aug 18, 2023
1 parent 6019c51 commit 9765bc4
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions native/Avalonia.Native/src/OSX/platformthreading.mm
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ virtual void Cancel() override
Cancelled = true;
if(Running)
{
Running = false;
if(![NSThread isMainThread])
{
AddRef();
Expand All @@ -28,22 +27,22 @@ virtual void Cancel() override
});
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];
}
};
};
Expand Down

0 comments on commit 9765bc4

Please sign in to comment.