rdit-ch / itemframework

A Qt-based application framework that allows users to define units and control the flow of data between them.
https://rdit.ch
8 stars 9 forks source link

SettingsScope not deleted when project is closed #5

Open t-moe opened 7 years ago

t-moe commented 7 years ago

Bug added by Alain on gitlab.

If you close a project (or the application), the SettingsScope of the project is still valid and not deleted, making it impossible (I think) to detect if a project is closed when you only have the SettingsScope.

t-moe commented 7 years ago

Answer by @timoll on gitlab.

Can you try with the new version of the itemframework?

I included a qDebug message in the destroyer of the setting scope, project, and workspace, here is the result:

Startup finished. Application Version: "0.1-30-gaed6e29"
//open/close projectsm, switch workspaces, setting scopes of items get destroyed
Destroy SettingScope:  "net-graph9"
Destroy SettingScope:  "shell processor1_copy1"
Destroy SettingScope:  "viewer1_copy1"
Destroy SettingScope:  "net-graph7"
Destroy SettingScope:  "shell processor1_copy1"
Destroy SettingScope:  "viewer1_copy1"
Destroy SettingScope:  "net-graph5"
Destroy SettingScope:  "shell processor1_copy1"
Destroy SettingScope:  "viewer1_copy1"
Destroy SettingScope:  "net-graph5"
Destroy SettingScope:  "shell processor1_copy1"
Destroy SettingScope:  "viewer1_copy1"
Destroy SettingScope:  "net-graph11"
Destroy SettingScope:  "shell processor1_copy1"
Destroy SettingScope:  "viewer1_copy1"
Destroy SettingScope:  "net-graph19"
Destroy SettingScope:  "shell processor1_copy1"
Destroy SettingScope:  "viewer1_copy1"

//Close Application with Ctrl+Q(normal close should have the same effect
Destroy Workspace:  "workspace_1"
Destroy Abstract Workspace:  "workspace_1"
Destroy File Project:  "project_1_1"
Destroy Abstract Project:  "project_1_1"
Destroy SettingScope:  "project_1_1"
Destroy File Project:  "project_1_2"
Destroy Abstract Project:  "project_1_2"
Destroy SettingScope:  "project_1_2"
Destroy File Project:  "project_1_3"
Destroy Abstract Project:  "project_1_3"
Destroy SettingScope:  "project_1_3"
Destroy SettingScope:  "workspace_1"
Destroy Workspace:  "workspace_2"
Destroy Abstract Workspace:  "workspace_2"
Destroy File Project:  "project_2_1"
Destroy Abstract Project:  "project_2_1"
Destroy SettingScope:  "project_2_1"
Destroy File Project:  "project_2_2"
Destroy Abstract Project:  "project_2_2"
Destroy SettingScope:  "project_2_2"
Destroy File Project:  "project_2_3"
Destroy Abstract Project:  "project_2_3"
Destroy SettingScope:  "project_2_3"
Destroy SettingScope:  "workspace_2"
Destroy Workspace:  "workspace_3"
Destroy Abstract Workspace:  "workspace_3"
Destroy File Project:  "project_3_1"
Destroy Abstract Project:  "project_3_1"
Destroy SettingScope:  "project_3_1"
Destroy File Project:  "project_3_2"
Destroy Abstract Project:  "project_3_2"
Destroy SettingScope:  "project_3_2"
Destroy File Project:  "project_3_3"
Destroy Abstract Project:  "project_3_3"
Destroy SettingScope:  "project_3_3"
Destroy SettingScope:  "workspace_3"

As you can see the, every setting scope gets deleted after its project or workspace is deleted.

Can you supply an example project and code where the problem occurs?

Shadowigor commented 7 years ago

Now that roviz is available, you can test it for yourself:

Relevant part of the code:

_usercore/src/gui/sharedwindow.cpp:321 connect(proj, &QObject::destroyed, sw, &SharedWindow::destroy);

The destroy function is not called, meaning, that the SettingsScope is not deleted.

t-moe commented 7 years ago

Ok. I investigated this a bit. You're both right. All SettingsScopes get destroyed when the application terminates but this is too late. The application will only terminate if all windows are closed.

This is the current call stack:

1  SettingsScope::~SettingsScope                                                                                  settings_scope.cpp      43  0x7ffff78a043d 
2  SettingsScope::~SettingsScope                                                                                  settings_scope.cpp      46  0x7ffff78a04b4 
3  QScopedPointerDeleter<SettingsScope>::cleanup                                                                  qscopedpointer.h        54  0x7ffff78b5517 
4  QScopedPointer<SettingsScope, QScopedPointerDeleter<SettingsScope>>::~QScopedPointer                           qscopedpointer.h        101 0x7ffff78b4445 
5  AbstractProject::~AbstractProject                                                                              abstract_project.cpp    13  0x7ffff79191ee 
6  FileProject::~FileProject                                                                                      file_project.cpp        35  0x7ffff791ae54 
7  FileProject::~FileProject                                                                                      file_project.cpp        37  0x7ffff791ae70 
8  QtSharedPointer::CustomDeleter<FileProject, QtSharedPointer::NormalDeleter>::execute                           qsharedpointer_impl.h   192 0x7ffff78f1745 
9  QtSharedPointer::ExternalRefCountWithCustomDeleter<FileProject, QtSharedPointer::NormalDeleter>::deleter       qsharedpointer_impl.h   210 0x7ffff78f1103 
10 QtSharedPointer::ExternalRefCountData::destroy                                                                 qsharedpointer_impl.h   154 0x7ffff788a42f 
11 QSharedPointer<AbstractProject>::deref                                                                         qsharedpointer_impl.h   493 0x7ffff78b62dd 
12 QSharedPointer<AbstractProject>::deref                                                                         qsharedpointer_impl.h   488 0x7ffff78b5d48 
13 QSharedPointer<AbstractProject>::~QSharedPointer                                                               qsharedpointer_impl.h   309 0x7ffff78b4e8a 
14 QVector<QSharedPointer<AbstractProject>>::destruct                                                             qvector.h               345 0x7ffff78ee182 
15 QVector<QSharedPointer<AbstractProject>>::freeData                                                             qvector.h               521 0x7ffff78ed77b 
16 QVector<QSharedPointer<AbstractProject>>::~QVector                                                             qvector.h               69  0x7ffff78ed1aa 
17 AbstractWorkspace::~AbstractWorkspace                                                                          abstract_workspace.cpp  13  0x7ffff78eaffe 
18 FileWorkspace::~FileWorkspace                                                                                  file_workspace.cpp      9   0x7ffff78ee7c4 
19 FileWorkspace::~FileWorkspace                                                                                  file_workspace.cpp      11  0x7ffff78ee7e0 
20 QtSharedPointer::CustomDeleter<AbstractWorkspace, QtSharedPointer::NormalDeleter>::execute                     qsharedpointer_impl.h   192 0x7ffff790bb2f 
21 QtSharedPointer::ExternalRefCountWithCustomDeleter<AbstractWorkspace, QtSharedPointer::NormalDeleter>::deleter qsharedpointer_impl.h   210 0x7ffff790b9fb 
22 QtSharedPointer::ExternalRefCountData::destroy                                                                 qsharedpointer_impl.h   154 0x7ffff788a42f 
23 QSharedPointer<AbstractWorkspace>::deref                                                                       qsharedpointer_impl.h   493 0x7ffff788d879 
24 QSharedPointer<AbstractWorkspace>::deref                                                                       qsharedpointer_impl.h   488 0x7ffff788ca16 
25 QSharedPointer<AbstractWorkspace>::~QSharedPointer                                                             qsharedpointer_impl.h   309 0x7ffff788ad84 
26 ProjectManager::~ProjectManager                                                                                project_manager.cpp     13  0x7ffff7909c80 
27 ProjectManager::~ProjectManager                                                                                project_manager.cpp     16  0x7ffff7909cc8 
28 ProjectManagerGui::~ProjectManagerGui                                                                          project_manager_gui.cpp 64  0x7ffff7905bc0 
29 ProjectManagerGui::~ProjectManagerGui                                                                          project_manager_gui.cpp 65  0x7ffff7905c30 
30 ObjectState::destroy                                                                                           startup_helper.cpp      372 0x7ffff789e7a6 
31 StartupHelperPrivate::stop                                                                                     startup_helper.cpp      149 0x7ffff789d4cd 
32 stop_handler                                                                                                   startup_helper.cpp      65  0x7ffff789cd0b 
33 qt_call_post_routines                                                                                          qcoreapplication.cpp    298 0x7ffff62a8394 
34 QApplication::~QApplication                                                                                    qapplication.cpp        825 0x7ffff6e9a59c 
35 main                                                                                                           main.cpp                7   0x400fe3       

This is a project manager "bug". Possible fixes: