Browse Source

【轻会员】注销验证码crash 修复

lizhe 1 year ago
parent
commit
55633c09ff

+ 30 - 24
PDF Office/PDF Master/Class/KMLightMember/Controller/VerificationCode/KMVerficationCodeWindowController.swift

@@ -66,16 +66,18 @@ class KMVerficationCodeWindowController: NSWindowController {
         self.verificationCodeView.doneAction = { [unowned self] (view, data , sender) in
             print("注销")
             KMRequestServerManager.manager.logOff(verifyCode: data.verifyCode, complete: { [unowned self] success, result in
-                if success {
-                    verficationCodeMainWindow?.endSheet(view.window!)
-                    view.window?.close()
-                    verficationCodeController = nil
-                    verficationCodeMainWindow = nil
-                    self.didCancellation?()
-                } else {
-                    self.verificationCodeView.showAlert(result: result)
+                if self.verificationCodeView != nil {
+                    if success {
+                        verficationCodeMainWindow?.endSheet(view.window!)
+                        view.window?.close()
+                        verficationCodeController = nil
+                        verficationCodeMainWindow = nil
+                        self.didCancellation?()
+                    } else {
+                        self.verificationCodeView.showAlert(result: result)
+                    }
+                    self.verificationCodeView.changeDoneButtonState(enable: true)
                 }
-                self.verificationCodeView.changeDoneButtonState(enable: true)
             })
         }
         
@@ -85,11 +87,13 @@ class KMVerficationCodeWindowController: NSWindowController {
         
         self.verificationCodeView.verificationCodeAction = { [unowned self] (view, data, codeString) in
             KMRequestServerManager.manager.verificationCode(account: data.email, verifyCode: codeString, verifyCodeType: view.verifyCodeType) { success, result in
-                if success {
-                    self.verificationCodeView.updateNetworkingState(complete: true, codeIsTure: true)
-                } else {
-                    self.verificationCodeView.updateNetworkingState(complete: true, codeIsTure: false)
-                    self.verificationCodeView.showAlert(result: result)
+                if self.verificationCodeView != nil {
+                    if success {
+                        self.verificationCodeView.updateNetworkingState(complete: true, codeIsTure: true)
+                    } else {
+                        self.verificationCodeView.updateNetworkingState(complete: true, codeIsTure: false)
+                        self.verificationCodeView.showAlert(result: result)
+                    }
                 }
             }
         }
@@ -107,16 +111,18 @@ class KMVerficationCodeWindowController: NSWindowController {
     
     func sendVerifyCode(sender: NSTextView?) {
         KMRequestServerManager.manager.getVerifyCode(verifyCodeType: self.verificationCodeView.verifyCodeType, email: self.verificationCodeView.model.email) { [unowned self] success, result in
-            if success {
-                self.verificationCodeView.resetTimer()
-            } else {
-                self.verificationCodeView.showAlert(result: result)
-                self.verificationCodeView.time = self.verificationCodeView.startTime
-                self.verificationCodeView.updateLanguage()
-            }
-            
-            if sender != nil {
-                sender!.isSelectable = true
+            if self.verificationCodeView != nil {
+                if success {
+                    self.verificationCodeView.resetTimer()
+                } else {
+                    self.verificationCodeView.showAlert(result: result)
+                    self.verificationCodeView.time = self.verificationCodeView.startTime
+                    self.verificationCodeView.updateLanguage()
+                }
+                
+                if sender != nil {
+                    sender!.isSelectable = true
+                }
             }
         }
     }

+ 5 - 0
PDF Office/PDF Master/Class/KMLightMember/Controller/VerificationCode/View/KMVerificationCodeView.swift

@@ -96,6 +96,11 @@ class KMVerificationCodeView: KMBaseXibView {
     var codeIsTrue: Bool = false //验证码是否正确
     var model: KMRegisterModel = KMRegisterModel()
     
+    deinit {
+        self.endTimer()
+        print("KMVerificationCodeView dealloc")
+    }
+    
     override func draw(_ dirtyRect: NSRect) {
         super.draw(dirtyRect)