Skip to content

Solve plugin destruction crash by avoiding Qt double deletion #238

Merged
ThomasKroes merged 1 commit intomasterfrom
feature/fix_closing_crash
Mar 4, 2026
Merged

Solve plugin destruction crash by avoiding Qt double deletion #238
ThomasKroes merged 1 commit intomasterfrom
feature/fix_closing_crash

Conversation

@ThomasKroes
Copy link
Contributor

This pull request refactors how SettingsAction and HorizontalToolbarAction are managed within ScatterplotPlugin and related classes. The main change is converting these from value members to pointer members, which requires updating how they are accessed throughout the codebase. Additionally, there are updates to how parent-child relationships are handled for these actions, and several instances now use dynamic_cast to retrieve the correct parent action. These changes improve object lifetime management and align with Qt best practices.

Key changes include:

Refactoring to Pointer Members:

Parent/Child Relationship and Action Access:

  • Updated constructors and methods to use dynamic_cast to retrieve SettingsAction* from the parent where appropriate, improving type safety and clarity. [1] [2] [3] [4]

These changes modernize the code and reduce the risk of object slicing or lifetime issues, making the codebase more robust and maintainable.

Convert SettingsAction and HorizontalToolbarAction members to QPointer types and create them with new, updating construction and all call sites accordingly. Update ScatterplotPlugin::getSettingsAction() to return a reference to the dereferenced QPointer. Replace direct member accesses with pointer-style (->) calls and adjust several call sites to obtain SettingsAction via dynamic_cast from parent()/parent()->parent() where appropriate (DatasetsAction, DensityPlotAction). Miscellaneous fixes: update toolbar widget creation, parent assignment, and serialization calls to use the new pointer members; small formatting and reference adjustments throughout impacted files.
@ThomasKroes ThomasKroes self-assigned this Mar 2, 2026
@ThomasKroes ThomasKroes added the bug Something isn't working label Mar 2, 2026
@ThomasKroes ThomasKroes linked an issue Mar 2, 2026 that may be closed by this pull request
@ThomasKroes ThomasKroes requested review from alxvth and sbvis March 2, 2026 13:49
@ThomasKroes ThomasKroes merged commit e1bac5f into master Mar 4, 2026
7 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Plugin destruction causes crash

2 participants