mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-26 15:10:22 -05:00
Fix critical QWidgetItem memory leak in ensureWidgetContainsEmptyGridLayout
Address sanitizer detected a 1056-byte memory leak in QWidgetItem objects. This was the actual root cause of the leak reported in the stack trace. Problem: In ensureWidgetContainsEmptyGridLayout(), when clearing existing layouts, the code was calling layout->takeAt(0) to remove QLayoutItem objects but never deleting them. This caused QWidgetItem objects to accumulate in memory without ever being freed. The takeAt() method removes items from the layout but does NOT delete them. The caller is responsible for deleting the returned QLayoutItem objects. Fix: Added `delete item;` in the cleanup loop to properly free QWidgetItem objects when clearing layouts before rebuilding the UI.
This commit is contained in:
1 parent
2f4f97c80b
commit
25dd9db293
1 file changed
+1
@@ -454,6 +454,7 @@ void caf::PdmUiFormLayoutObjectEditor::ensureWidgetContainsEmptyGridLayout( QWid
|
||||
QLayoutItem* item;
|
||||
while ( ( item = layout->takeAt( 0 ) ) != 0 )
|
||||
{
|
||||
delete item;
|
||||
}
|
||||
QWidget().setLayout( layout );
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user