From 589ff8c78928da513e3d274882717526f2f5d05c Mon Sep 17 00:00:00 2001 From: Ryan McGrath Date: Mon, 1 May 2023 03:47:35 -0700 Subject: [PATCH] Fixes #82 --- src/appkit/app/mod.rs | 4 ++-- src/appkit/menu/item.rs | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/appkit/app/mod.rs b/src/appkit/app/mod.rs index 3ff2b6e..9828855 100644 --- a/src/appkit/app/mod.rs +++ b/src/appkit/app/mod.rs @@ -69,7 +69,7 @@ pub(crate) static APP_PTR: &str = "rstAppPtr"; /// A handler to make some boilerplate less annoying. #[inline] -fn shared_application T>(handler: F) -> T { +pub(crate) fn shared_application T>(handler: F) -> T { let app: id = unsafe { msg_send![register_app_class(), sharedApplication] }; handler(app) } @@ -123,7 +123,7 @@ impl App { pub fn run(&self) { unsafe { //let current_app: id = msg_send![class!(NSRunningApplication), currentApplication]; - let shared_app: id = msg_send![class!(RSTApplication), sharedApplication]; + let shared_app: id = msg_send![register_app_class(), sharedApplication]; let _: () = msg_send![shared_app, run]; self.pool.drain(); } diff --git a/src/appkit/menu/item.rs b/src/appkit/menu/item.rs index 6c7298d..6218e19 100644 --- a/src/appkit/menu/item.rs +++ b/src/appkit/menu/item.rs @@ -165,8 +165,12 @@ impl MenuItem { // supported by MenuItem yet. Self::Services => { let item = make_menu_item("Services", None, None, None); - let app: id = msg_send![class!(RSTApplication), sharedApplication]; - let services: id = msg_send![app, servicesMenu]; + + let services = crate::appkit::app::shared_application(|app| { + let services: id = msg_send![app, servicesMenu]; + services + }); + let _: () = msg_send![&*item, setSubmenu: services]; item },