fix(QAbstractItemModel): Fixing memory leaks and crash when using startupModule after the object is deleted
This commit is contained in:
parent
8a2bb3e40f
commit
79b4d7638a
|
@ -281,6 +281,7 @@ proc delete*(self: AppController) =
|
||||||
self.gifService.delete
|
self.gifService.delete
|
||||||
if not self.startupModule.isNil:
|
if not self.startupModule.isNil:
|
||||||
self.startupModule.delete
|
self.startupModule.delete
|
||||||
|
self.startupModule = nil
|
||||||
self.mainModule.delete
|
self.mainModule.delete
|
||||||
self.languageService.delete
|
self.languageService.delete
|
||||||
|
|
||||||
|
@ -460,6 +461,7 @@ proc finishAppLoading*(self: AppController) =
|
||||||
|
|
||||||
if not self.startupModule.isNil:
|
if not self.startupModule.isNil:
|
||||||
self.startupModule.delete
|
self.startupModule.delete
|
||||||
|
self.startupModule = nil
|
||||||
|
|
||||||
proc logout*(self: AppController) =
|
proc logout*(self: AppController) =
|
||||||
self.generalService.logout()
|
self.generalService.logout()
|
||||||
|
|
|
@ -65,11 +65,16 @@ proc newModule*[T](delegate: T,
|
||||||
profileService, keycardService)
|
profileService, keycardService)
|
||||||
|
|
||||||
method delete*[T](self: Module[T]) =
|
method delete*[T](self: Module[T]) =
|
||||||
|
singletonInstance.engine.setRootContextProperty("startupModule", newQVariant())
|
||||||
self.view.delete
|
self.view.delete
|
||||||
|
self.view = nil
|
||||||
self.viewVariant.delete
|
self.viewVariant.delete
|
||||||
|
self.viewVariant = nil
|
||||||
self.controller.delete
|
self.controller.delete
|
||||||
|
self.controller = nil
|
||||||
if not self.keycardSharedModule.isNil:
|
if not self.keycardSharedModule.isNil:
|
||||||
self.keycardSharedModule.delete
|
self.keycardSharedModule.delete
|
||||||
|
self.keycardSharedModule = nil
|
||||||
|
|
||||||
proc extractImages(self: Module, account: AccountDto, thumbnailImage: var string,
|
proc extractImages(self: Module, account: AccountDto, thumbnailImage: var string,
|
||||||
largeImage: var string) =
|
largeImage: var string) =
|
||||||
|
@ -394,10 +399,10 @@ method onNodeLogin*[T](self: Module[T], error: string) =
|
||||||
if err.len > 0:
|
if err.len > 0:
|
||||||
self.logoutAndDisplayError(err, StartupErrorType.UnknownType)
|
self.logoutAndDisplayError(err, StartupErrorType.UnknownType)
|
||||||
return
|
return
|
||||||
self.delegate.finishAppLoading()
|
|
||||||
if currStateObj.flowType() != FlowType.AppLogin:
|
if currStateObj.flowType() != FlowType.AppLogin:
|
||||||
discard self.controller.storeIdentityImage()
|
discard self.controller.storeIdentityImage()
|
||||||
self.controller.cleanTmpData()
|
self.controller.cleanTmpData()
|
||||||
|
self.delegate.finishAppLoading()
|
||||||
else:
|
else:
|
||||||
self.moveToStartupState()
|
self.moveToStartupState()
|
||||||
if currStateObj.flowType() == FlowType.AppLogin:
|
if currStateObj.flowType() == FlowType.AppLogin:
|
||||||
|
|
Loading…
Reference in New Issue