Ver código fonte

【多页签】通知事件优化

tangchao 9 meses atrás
pai
commit
69e75a9986

+ 31 - 0
PDF Office/PDF Master/Class/ChromiumTabs/src/Tab Strip/CTTabStripController.m

@@ -1730,6 +1730,9 @@ const NSTimeInterval kAnimationDuration = 0.125;
 #pragma mark Delegate methods
 
 - (void)tabDidInsert:(NSNotification *)notification {
+    if (![self _tabStripModelIsValid:notification.object]) {
+        return;
+    }
 	NSDictionary *userInfo = notification.userInfo;
 	CTTabContents *contents = [userInfo valueForKey:CTTabContentsUserInfoKey];
 	NSInteger modelIndex = [[userInfo valueForKey:CTTabIndexUserInfoKey] intValue];
@@ -1804,6 +1807,10 @@ const NSTimeInterval kAnimationDuration = 0.125;
 }
 
 - (void)tabDidSelect:(NSNotification *)notification {
+    if (![self _tabStripModelIsValid:notification.object]) {
+        return;
+    }
+    
 	NSDictionary *userInfo = notification.userInfo;
 	CTTabContents *newContents = [userInfo valueForKey:CTTabNewContentsUserInfoKey];
 	CTTabContents *oldContents = [userInfo valueForKey:CTTabContentsUserInfoKey];
@@ -1870,6 +1877,10 @@ const NSTimeInterval kAnimationDuration = 0.125;
 }
 
 - (void)tabDidChange:(NSNotification *)notification {
+    if (![self _tabStripModelIsValid:notification.object]) {
+        return;
+    }
+    
 	NSDictionary *userInfo = notification.userInfo;
 	CTTabContents *contents = [userInfo valueForKey:CTTabContentsUserInfoKey];
 	NSInteger modelIndex = [[userInfo valueForKey:CTTabIndexUserInfoKey] intValue];
@@ -1905,6 +1916,10 @@ const NSTimeInterval kAnimationDuration = 0.125;
 }
 
 - (void)tabDidMove:(NSNotification *)notification {
+    if (![self _tabStripModelIsValid:notification.object]) {
+        return;
+    }
+    
 	NSDictionary *userInfo = notification.userInfo;
 	CTTabContents *contents = [userInfo valueForKey:CTTabContentsUserInfoKey];
 	NSInteger modelFrom = [[userInfo valueForKey:CTTabIndexUserInfoKey] intValue];
@@ -1937,6 +1952,9 @@ const NSTimeInterval kAnimationDuration = 0.125;
 }
 
 - (void)tabDidChangeMiniState:(NSNotification *)notification {
+    if (![self _tabStripModelIsValid:notification.object]) {
+        return;
+    }
 	NSDictionary *userInfo = notification.userInfo;
 	CTTabContents *contents = [userInfo valueForKey:CTTabContentsUserInfoKey];
 	NSInteger modelIndex = [[userInfo valueForKey:CTTabIndexUserInfoKey] intValue];
@@ -1962,6 +1980,10 @@ const NSTimeInterval kAnimationDuration = 0.125;
 }
 
 - (void)tabDidDetach:(NSNotification *)notification {
+    if (![self _tabStripModelIsValid:notification.object]) {
+        return;
+    }
+    
 	NSDictionary *userInfo = notification.userInfo;
 	CTTabContents *contents = [userInfo valueForKey:CTTabContentsUserInfoKey];
 	NSInteger modelIndex = [[userInfo valueForKey:CTTabIndexUserInfoKey] intValue];
@@ -1989,6 +2011,15 @@ const NSTimeInterval kAnimationDuration = 0.125;
 														object:self];
 }
 
+#pragma mark - Private Methods
+
+- (BOOL)_tabStripModelIsValid:(CTTabStripModel *)obj {
+    if (self->tabStripModel_ == nil || ![self->tabStripModel_ isEqualTo:obj]) {
+        return false;
+    }
+    return true;
+}
+
 @end
 
 @implementation CTTabStripController (KMExtensions)

+ 6 - 6
PDF Office/PDF Master/Class/Document/KMMainDocument.swift

@@ -179,12 +179,12 @@ typealias KMMainDocumentCloudUploadHanddler = (@escaping(Bool, String)->()) -> (
             }
         }
         
-        if (currentWindowController == nil) && (self.fileURL != nil) {
-            let browser = KMBrowser.init() as KMBrowser
-            browser.addHomeTabContents()
-            browser.windowController = KMBrowserWindowController.init(browser: browser)
-            currentWindowController = browser.windowController as? KMBrowserWindowController
-        }
+//        if (currentWindowController == nil) && (self.fileURL != nil) {
+//            let browser = KMBrowser.init() as KMBrowser
+//            browser.addHomeTabContents()
+//            browser.windowController = KMBrowserWindowController.init(browser: browser)
+//            currentWindowController = browser.windowController as? KMBrowserWindowController
+//        }
         
         if currentWindowController?.browser == nil && (self.fileURL != nil) {
             let browser: KMBrowser = KMBrowser.init()