I am trying to close QgsProject on loading layer (if password and username from QgSProject - datasource are incorrect) before QgsCredentialDialog is shown.
on signal :
QgsProject.instance().loadingLayer.connect(self.load_log)
If password and user are correct -> pass
if password and user are not correct: close the project
I am using :
project = QgsProject.instance()
project.clear()
but QgsCredentialDialog still shows up.
after clear project if I use :
iface.actionExit().trigger()
This shows up:
If I click yes, QgsCredentialDialog is shown again
How do I close the project and everything connected with that project (signals,actions,tasks,connections,...)?
NOTE:
QgsTaskManager().cancelAll() # NOT WORKING
tasks = QgsApplication.taskManager().activeTasks()
for task in tasks:
print (task.canCancel()) # False
print (task.description()) # Loading “C:/Users/User/Desktop/some_project.qgs”
print (task.flags()) #
task.cancel() # NOT WORKING
Since task.canCancel() is FALSE (I think that is main problem here), is it possible to change task.canCancel() into TRUE?
No comments:
Post a Comment