From 1f2ed702884d72f82b651612617926540080f05f Mon Sep 17 00:00:00 2001 From: Brandon Wees Date: Tue, 19 May 2026 04:13:07 -0500 Subject: [PATCH] fix: macOS deep links after wxWidgets 3.3.2 upgrade (#13737) Fix macOS orcaslicer:// deep links after wxWidgets 3.3.2 upgrade Install an OrcaSlicer-owned kAEGetURL Apple Event handler from on_init_inner(). The wxWidgets 3.3.2 handler registered in applicationWillFinishLaunching: stopped delivering URL events to GUI_App::MacOpenURL on macOS (#13119), so links from Printables / Thingiverse opened a blank project instead of importing the model. Registering our own handler late in startup is last-writer-wins on NSAppleEventManager and routes back to the existing MacOpenURL -> start_download path, restoring the pre-upgrade behavior without touching wxWidgets. Co-authored-by: Claude Opus 4.7 --- src/slic3r/CMakeLists.txt | 2 ++ src/slic3r/GUI/DeepLinkHandlerMac.h | 16 +++++++++++ src/slic3r/GUI/DeepLinkHandlerMac.mm | 41 ++++++++++++++++++++++++++++ src/slic3r/GUI/GUI_App.cpp | 9 ++++++ 4 files changed, 68 insertions(+) create mode 100644 src/slic3r/GUI/DeepLinkHandlerMac.h create mode 100644 src/slic3r/GUI/DeepLinkHandlerMac.mm diff --git a/src/slic3r/CMakeLists.txt b/src/slic3r/CMakeLists.txt index 5e502207ef..c4d6369b72 100644 --- a/src/slic3r/CMakeLists.txt +++ b/src/slic3r/CMakeLists.txt @@ -687,6 +687,8 @@ if (APPLE) GUI/Mouse3DHandlerMac.mm GUI/InstanceCheckMac.mm GUI/InstanceCheckMac.h + GUI/DeepLinkHandlerMac.mm + GUI/DeepLinkHandlerMac.h GUI/GUI_UtilsMac.mm GUI/wxMediaCtrl2.mm GUI/wxMediaCtrl2.h diff --git a/src/slic3r/GUI/DeepLinkHandlerMac.h b/src/slic3r/GUI/DeepLinkHandlerMac.h new file mode 100644 index 0000000000..e9877e3868 --- /dev/null +++ b/src/slic3r/GUI/DeepLinkHandlerMac.h @@ -0,0 +1,16 @@ +#ifndef slic3r_GUI_DeepLinkHandlerMac_h_ +#define slic3r_GUI_DeepLinkHandlerMac_h_ + +namespace Slic3r { +namespace GUI { + +// Re-registers a Cocoa Apple Event handler for kInternetEventClass/kAEGetURL. +// Works around a regression observed after upgrading to wxWidgets 3.3.2 on +// macOS Tahoe (#13119) where wxWidgets' built-in handler is registered but +// never fires for orcaslicer:// deep links. +void register_mac_deep_link_handler(); + +} // namespace GUI +} // namespace Slic3r + +#endif diff --git a/src/slic3r/GUI/DeepLinkHandlerMac.mm b/src/slic3r/GUI/DeepLinkHandlerMac.mm new file mode 100644 index 0000000000..fd3d8272ff --- /dev/null +++ b/src/slic3r/GUI/DeepLinkHandlerMac.mm @@ -0,0 +1,41 @@ +#import +#import + +#include + +#include "DeepLinkHandlerMac.h" +#include "GUI_App.hpp" + +@interface OrcaDeepLinkHandler : NSObject +- (void)handleGetURLEvent:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)reply; +@end + +@implementation OrcaDeepLinkHandler +- (void)handleGetURLEvent:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)reply +{ + NSString *url = [[event paramDescriptorForKeyword:keyDirectObject] stringValue]; + if (url == nil || url.length == 0) + return; + BOOST_LOG_TRIVIAL(info) << "Deep link received: " << [url UTF8String]; + Slic3r::GUI::wxGetApp().MacOpenURL(wxString::FromUTF8([url UTF8String])); +} +@end + +namespace Slic3r { +namespace GUI { + +void register_mac_deep_link_handler() +{ + static OrcaDeepLinkHandler *handler = nil; + if (handler == nil) + handler = [[OrcaDeepLinkHandler alloc] init]; + + [[NSAppleEventManager sharedAppleEventManager] + setEventHandler:handler + andSelector:@selector(handleGetURLEvent:withReplyEvent:) + forEventClass:kInternetEventClass + andEventID:kAEGetURL]; +} + +} // namespace GUI +} // namespace Slic3r diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index 889cccde0f..b5204e1d49 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -100,6 +100,9 @@ #include "Mouse3DController.hpp" #include "RemovableDriveManager.hpp" #include "InstanceCheck.hpp" +#ifdef __APPLE__ +#include "DeepLinkHandlerMac.h" +#endif #include "NotificationManager.hpp" #include "UnsavedChangesDialog.hpp" #include "SavePresetDialog.hpp" @@ -2547,6 +2550,12 @@ std::string get_system_info() bool GUI_App::on_init_inner() { wxLog::SetActiveTarget(new wxBoostLog()); + +#ifdef __APPLE__ + // Override wxWidgets' kAEGetURL handler so orcaslicer:// deep links keep + // working after the wxWidgets 3.3.2 upgrade on macOS (#13119). + register_mac_deep_link_handler(); +#endif #if BBL_RELEASE_TO_PUBLIC wxLog::SetLogLevel(wxLOG_Message); #endif