Fix some invalid msg_send! usage (#2138)
* Fix some invalid msg_send! usage * Make the implementation of superclass clearer
This commit is contained in:
parent
8af222c1e3
commit
2a2abc4843
9 changed files with 53 additions and 45 deletions
|
|
@ -10,7 +10,7 @@ use cocoa::{
|
|||
};
|
||||
use dispatch::Queue;
|
||||
use objc::rc::autoreleasepool;
|
||||
use objc::runtime::NO;
|
||||
use objc::runtime::{BOOL, NO};
|
||||
|
||||
use crate::{
|
||||
dpi::LogicalSize,
|
||||
|
|
@ -51,7 +51,8 @@ pub unsafe fn set_style_mask_async(ns_window: id, ns_view: id, mask: NSWindowSty
|
|||
});
|
||||
}
|
||||
pub unsafe fn set_style_mask_sync(ns_window: id, ns_view: id, mask: NSWindowStyleMask) {
|
||||
if msg_send![class!(NSThread), isMainThread] {
|
||||
let is_main_thread: BOOL = msg_send!(class!(NSThread), isMainThread);
|
||||
if is_main_thread != NO {
|
||||
set_style_mask(ns_window, ns_view, mask);
|
||||
} else {
|
||||
let ns_window = MainThreadSafe(ns_window);
|
||||
|
|
|
|||
|
|
@ -40,10 +40,9 @@ impl IdRef {
|
|||
IdRef(inner)
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn retain(inner: id) -> IdRef {
|
||||
if inner != nil {
|
||||
let () = unsafe { msg_send![inner, retain] };
|
||||
let _: id = unsafe { msg_send![inner, retain] };
|
||||
}
|
||||
IdRef(inner)
|
||||
}
|
||||
|
|
@ -76,10 +75,7 @@ impl Deref for IdRef {
|
|||
|
||||
impl Clone for IdRef {
|
||||
fn clone(&self) -> IdRef {
|
||||
if self.0 != nil {
|
||||
let _: id = unsafe { msg_send![self.0, retain] };
|
||||
}
|
||||
IdRef(self.0)
|
||||
IdRef::retain(self.0)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -118,8 +114,8 @@ pub unsafe fn app_name() -> Option<id> {
|
|||
}
|
||||
|
||||
pub unsafe fn superclass<'a>(this: &'a Object) -> &'a Class {
|
||||
let superclass: id = msg_send![this, superclass];
|
||||
&*(superclass as *const _)
|
||||
let superclass: *const Class = msg_send![this, superclass];
|
||||
&*superclass
|
||||
}
|
||||
|
||||
pub unsafe fn create_input_context(view: id) -> IdRef {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue