mirror of
https://github.com/OPM/ResInsight.git
synced 2026-11-23 14:28:13 -06:00
Guard dock splitters against deletion before delayed rebalance
rebalanceDockSplitters captured raw CDockSplitter pointers in a 10 ms QTimer::singleShot lambda. The docking layout can delete splitters (e.g. when dock areas are removed while tiling) before the timer fires, so the lambda dereferenced a dangling pointer. Capture QPointer guards and skip splitters that have been destroyed. Crash signature fe96dd39756a: operator() at ApplicationLibCode/UserInterface/RiuMainWindowBase.cpp:79 RiaGuiApplication::notify(QObject*, QEvent*) at RiaGuiApplication.cpp:1879
This commit is contained in:
1 parent
82ade27714
commit
0d862856ff
1 file changed
+8
-2
@@ -53,6 +53,7 @@
|
||||
#include <QLabel>
|
||||
#include <QMenu>
|
||||
#include <QMessageBox>
|
||||
#include <QPointer>
|
||||
#include <QSettings>
|
||||
#include <QTextEdit>
|
||||
#include <QTimer>
|
||||
@@ -69,13 +70,18 @@ namespace internal
|
||||
{
|
||||
void rebalanceDockSplitters( RiuMainWindowBase* widget, std::set<ads::CDockSplitter*> splitters )
|
||||
{
|
||||
// The docking layout can delete splitters before the timer fires, so guard them with QPointer
|
||||
std::vector<QPointer<QSplitter>> guardedSplitters( splitters.begin(), splitters.end() );
|
||||
|
||||
// rebalance splitters after a short delay to allow the layout to be updated before setting sizes
|
||||
QTimer::singleShot( 10,
|
||||
widget,
|
||||
[splitters]()
|
||||
[guardedSplitters]()
|
||||
{
|
||||
for ( QSplitter* splitter : splitters )
|
||||
for ( const auto& splitter : guardedSplitters )
|
||||
{
|
||||
if ( !splitter ) continue;
|
||||
|
||||
QList<int> sizes( splitter->count(), 1000 ); // size not important, just needs all to be equal
|
||||
splitter->setSizes( sizes );
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user