Skip to content

Conversation

@jcfr
Copy link
Member

@jcfr jcfr commented Nov 9, 2025

Initialize d_ptr in the alternative ctkMessageBox constructor before calling d->init(), preventing a potential null dereference crash and addressing the compiler warning.

Fixes the following warning;

/path/to/CTK/Libs/Widgets/ctkMessageBox.cpp: In constructor ‘ctkMessageBox::ctkMessageBox(QMessageBox::Icon, const QString&, const QString&, QMessageBox::StandardButtons, QWidget*, Qt::WindowFlags)’:
/path/to/CTK/Libs/Widgets/ctkMessageBox.cpp:194:10: warning: ‘this’ pointer is null [-Wnonnull]
  194 |   d->init();
      |   ~~~~~~~^~

Initialize d_ptr in the alternative ctkMessageBox constructor before
calling d->init(), preventing a potential null dereference crash and
addressing the compiler warning.

Fixes the following warning;

```
/path/to/CTK/Libs/Widgets/ctkMessageBox.cpp: In constructor ‘ctkMessageBox::ctkMessageBox(QMessageBox::Icon, const QString&, const QString&, QMessageBox::StandardButtons, QWidget*, Qt::WindowFlags)’:
/path/to/CTK/Libs/Widgets/ctkMessageBox.cpp:194:10: warning: ‘this’ pointer is null [-Wnonnull]
  194 |   d->init();
      |   ~~~~~~~^~
```
@jcfr jcfr merged commit 727a3a3 into commontk:master Nov 9, 2025
3 checks passed
@jcfr jcfr deleted the fix-ctkMessageBox-constructor-warning branch November 9, 2025 02:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant