redsoft
25th June 2022, 18:00
Recently I needed to insert several buttons into QGraphicsScene and implemented it as it was described in Qt examples (I use Qt 5.15.2):
QMyWidget* widget;
// ...
// initializing widget, adding layout, adding 3 QPushButton’s to this layout
QMyGraphicsScene* scene;
// initializing some my scene
QGraphicsProxyWidget* proxy = scene->addWidget (widget);
Everything works fine, aside from a mysterious crash happening on the application exit. The crash appears on Linux and Android (not observed on Windows) deep in QApplication destructor.
What is very interesting, the crash happens only in the case, if any of the buttons present in the QGraphicsProxyWidget, was pressed during execution. If the application is started, then closed immediately without any user interaction with the buttons, - there is no crash!
During this problem investigation, I added full cleanup that is performed when just one my QMainWindow inheritor is closed:
proxy->setWidget (nullptr);
scene->removeItem (proxy);
delete proxy;
But this doesn’t help, and when all QWidget’s and QGraphicsScene are already destroyed, the crash still happens in QApplication::~QApplication.
Any help with this issue would be appreciated.
QMyWidget* widget;
// ...
// initializing widget, adding layout, adding 3 QPushButton’s to this layout
QMyGraphicsScene* scene;
// initializing some my scene
QGraphicsProxyWidget* proxy = scene->addWidget (widget);
Everything works fine, aside from a mysterious crash happening on the application exit. The crash appears on Linux and Android (not observed on Windows) deep in QApplication destructor.
What is very interesting, the crash happens only in the case, if any of the buttons present in the QGraphicsProxyWidget, was pressed during execution. If the application is started, then closed immediately without any user interaction with the buttons, - there is no crash!
During this problem investigation, I added full cleanup that is performed when just one my QMainWindow inheritor is closed:
proxy->setWidget (nullptr);
scene->removeItem (proxy);
delete proxy;
But this doesn’t help, and when all QWidget’s and QGraphicsScene are already destroyed, the crash still happens in QApplication::~QApplication.
Any help with this issue would be appreciated.