mirror of
https://github.com/Sunnyyoung/WeChatTweak-macOS.git
synced 2025-05-23 14:56:08 +08:00
Fixed potential crash on exit
This commit is contained in:
parent
701b8a3ad0
commit
b41fb3910d
|
@ -3,7 +3,7 @@
|
|||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>BuildMachineOSBuild</key>
|
||||
<string>17A365</string>
|
||||
<string>17C88</string>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
|
@ -27,17 +27,17 @@
|
|||
<key>DTCompiler</key>
|
||||
<string>com.apple.compilers.llvm.clang.1_0</string>
|
||||
<key>DTPlatformBuild</key>
|
||||
<string>9A235</string>
|
||||
<string>9C40b</string>
|
||||
<key>DTPlatformVersion</key>
|
||||
<string>GM</string>
|
||||
<key>DTSDKBuild</key>
|
||||
<string>17A360</string>
|
||||
<string>17C76</string>
|
||||
<key>DTSDKName</key>
|
||||
<string>macosx10.13</string>
|
||||
<key>DTXcode</key>
|
||||
<string>0900</string>
|
||||
<string>0920</string>
|
||||
<key>DTXcodeBuild</key>
|
||||
<string>9A235</string>
|
||||
<string>9C40b</string>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string>Copyright © 2017年 Sunnyyoung. All rights reserved.</string>
|
||||
</dict>
|
||||
|
|
Binary file not shown.
|
@ -46,7 +46,7 @@ static void __attribute__((constructor)) tweak(void) {
|
|||
// Method Swizzling
|
||||
class_addMethod(objc_getClass("AppDelegate"), @selector(applicationDockMenu:), method_getImplementation(class_getInstanceMethod(objc_getClass("AppDelegate"), @selector(tweak_applicationDockMenu:))), "@:@");
|
||||
[objc_getClass("AppDelegate") jr_swizzleMethod:NSSelectorFromString(@"applicationDidFinishLaunching:") withMethod:@selector(tweak_applicationDidFinishLaunching:) error:nil];
|
||||
[objc_getClass("AppDelegate") jr_swizzleMethod:NSSelectorFromString(@"applicationShouldTerminate:") withMethod:@selector(tweak_applicationShouldTerminate:) error:nil];
|
||||
[objc_getClass("LogoutCGI") jr_swizzleMethod:NSSelectorFromString(@"sendLogoutCGIWithCompletion:") withMethod:@selector(tweak_sendLogoutCGIWithCompletion:) error:nil];
|
||||
[objc_getClass("MessageService") jr_swizzleMethod:NSSelectorFromString(@"onRevokeMsg:") withMethod:@selector(tweak_onRevokeMsg:) error:nil];
|
||||
[objc_getClass("CUtility") jr_swizzleClassMethod:NSSelectorFromString(@"HasWechatInstance") withClassMethod:@selector(tweak_HasWechatInstance) error:nil];
|
||||
[objc_getClass("MASPreferencesWindowController") jr_swizzleMethod:NSSelectorFromString(@"initWithViewControllers:") withMethod:@selector(tweak_initWithViewControllers:) error:nil];
|
||||
|
@ -153,13 +153,13 @@ static void __attribute__((constructor)) tweak(void) {
|
|||
[[AlfredManager sharedInstance] startListener];
|
||||
}
|
||||
|
||||
- (NSApplicationTerminateReply)tweak_applicationShouldTerminate:(NSApplication *)sender {
|
||||
- (void)tweak_sendLogoutCGIWithCompletion:(id)completion {
|
||||
BOOL enabledAutoAuth = [[NSUserDefaults standardUserDefaults] boolForKey:WeChatTweakPreferenceAutoAuthKey];
|
||||
if (enabledAutoAuth) {
|
||||
return NSTerminateNow;
|
||||
} else {
|
||||
return [self tweak_applicationShouldTerminate:sender];
|
||||
WeChat *wechat = [objc_getClass("WeChat") sharedInstance];
|
||||
if (enabledAutoAuth && wechat.isAppTerminating) {
|
||||
return;
|
||||
}
|
||||
[self tweak_sendLogoutCGIWithCompletion:completion];
|
||||
}
|
||||
|
||||
#pragma mark - Preferences Window
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
|
||||
@interface WeChat : NSObject
|
||||
|
||||
@property(nonatomic) BOOL isAppTerminating;
|
||||
|
||||
+ (instancetype)sharedInstance;
|
||||
- (void)lock:(id)block;
|
||||
- (void)showMainWindow;
|
||||
|
@ -92,6 +94,12 @@
|
|||
|
||||
@end
|
||||
|
||||
@interface LogoutCGI: NSObject
|
||||
|
||||
- (void)sendLogoutCGIWithCompletion:(id)arg1;
|
||||
|
||||
@end
|
||||
|
||||
@protocol MASPreferencesViewController <NSObject>
|
||||
|
||||
@property(readonly, nonatomic) NSString *toolbarItemLabel;
|
||||
|
@ -104,7 +112,7 @@
|
|||
|
||||
@end
|
||||
|
||||
@interface MASPreferencesWindowController : NSWindowController
|
||||
@interface MASPreferencesWindowController: NSWindowController
|
||||
|
||||
- (id)initWithViewControllers:(NSArray *)arg1;
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user