Browse Source
fix macos crash at startup by not parsing all app arguments into uris. (#14494)
pull/14505/head
Dan Walmsley
3 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with
13 additions and
3 deletions
-
native/Avalonia.Native/src/OSX/app.mm
-
src/Avalonia.Native/AvaloniaNativeApplicationPlatform.cs
-
src/Avalonia.Native/avn.idl
|
|
|
@ -70,7 +70,7 @@ ComPtr<IAvnApplicationEvents> _events; |
|
|
|
{ |
|
|
|
auto array = CreateAvnStringArray(urls); |
|
|
|
|
|
|
|
_events->FilesOpened(array); |
|
|
|
_events->UrlsOpened(array); |
|
|
|
} |
|
|
|
|
|
|
|
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender |
|
|
|
|
|
|
|
@ -13,12 +13,21 @@ namespace Avalonia.Native |
|
|
|
void IAvnApplicationEvents.FilesOpened(IAvnStringArray urls) |
|
|
|
{ |
|
|
|
((IApplicationPlatformEvents)Application.Current).RaiseUrlsOpened(urls.ToStringArray()); |
|
|
|
} |
|
|
|
|
|
|
|
void IAvnApplicationEvents.UrlsOpened(IAvnStringArray urls) |
|
|
|
{ |
|
|
|
// Raise the urls opened event to be compatible with legacy behavior.
|
|
|
|
((IApplicationPlatformEvents)Application.Current).RaiseUrlsOpened(urls.ToStringArray()); |
|
|
|
|
|
|
|
if (Application.Current?.ApplicationLifetime is MacOSClassicDesktopStyleApplicationLifetime lifetime) |
|
|
|
{ |
|
|
|
foreach (var url in urls.ToStringArray()) |
|
|
|
{ |
|
|
|
lifetime.RaiseUrl(new Uri(url)); |
|
|
|
if (Uri.TryCreate(url, UriKind.RelativeOrAbsolute, out var uri)) |
|
|
|
{ |
|
|
|
lifetime.RaiseUrl(uri); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -1085,7 +1085,8 @@ interface IAvnNativeControlHostTopLevelAttachment : IUnknown |
|
|
|
[uuid(6575b5af-f27a-4609-866c-f1f014c20f79)] |
|
|
|
interface IAvnApplicationEvents : IUnknown |
|
|
|
{ |
|
|
|
void FilesOpened (IAvnStringArray* urls); |
|
|
|
void FilesOpened (IAvnStringArray* args); |
|
|
|
void UrlsOpened (IAvnStringArray* urls); |
|
|
|
bool TryShutdown(); |
|
|
|
void OnReopen (); |
|
|
|
void OnHide (); |
|
|
|
|