[Scummvm-git-logs] scummvm master -> c420983634b480523a61b91abaa4d8a50a2a2052

eriktorbjorn noreply at scummvm.org
Mon Nov 15 08:46:32 UTC 2021


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
c420983634 GUI: Don't leak tray dialogs


Commit: c420983634b480523a61b91abaa4d8a50a2a2052
    https://github.com/scummvm/scummvm/commit/c420983634b480523a61b91abaa4d8a50a2a2052
Author: Torbjörn Andersson (eriktorbjorn at users.sourceforge.net)
Date: 2021-11-15T09:46:01+01:00

Commit Message:
GUI: Don't leak tray dialogs

Since the dialog isn't used outside of the function, I've also made the
variables local.

Changed paths:
    gui/widgets/grid.cpp
    gui/widgets/grid.h


diff --git a/gui/widgets/grid.cpp b/gui/widgets/grid.cpp
index eeb6e75cf0..02819102f1 100644
--- a/gui/widgets/grid.cpp
+++ b/gui/widgets/grid.cpp
@@ -371,7 +371,6 @@ GridWidget::GridWidget(GuiObject *boss, const Common::String &name)
 	_trayHeight = kLineHeight * 3;
 
 	_selectedEntry = nullptr;
-	_tray = nullptr;
 	_isGridInvalid = true;
 }
 
@@ -852,15 +851,17 @@ void GridWidget::reflowLayout() {
 }
 
 void GridWidget::openTray(int x, int y, int entryId) {
-	_tray = new GridItemTray(this, x - _gridXSpacing / 3, y, _gridItemWidth + 2 * (_gridXSpacing / 3), _trayHeight, entryId, this);
-	_tray->runModal();
+	GridItemTray *tray = new GridItemTray(this, x - _gridXSpacing / 3, y, _gridItemWidth + 2 * (_gridXSpacing / 3), _trayHeight, entryId, this);
+	tray->runModal();
+	delete tray;
 }
 
 void GridWidget::openTrayAtSelected() {
 	if (_selectedEntry) {
-		_tray = new GridItemTray(this, _x + _selectedEntry->rect.left - _gridXSpacing / 3, _y + _selectedEntry->rect.bottom - _scrollPos,
+		GridItemTray *tray = new GridItemTray(this, _x + _selectedEntry->rect.left - _gridXSpacing / 3, _y + _selectedEntry->rect.bottom - _scrollPos,
 								_gridItemWidth + 2 * (_gridXSpacing / 3), _trayHeight, _selectedEntry->entryID, this);
-		_tray->runModal();
+		tray->runModal();
+		delete tray;
 	}
 }
 
diff --git a/gui/widgets/grid.h b/gui/widgets/grid.h
index dd63ce5bc7..8727726921 100644
--- a/gui/widgets/grid.h
+++ b/gui/widgets/grid.h
@@ -140,7 +140,6 @@ protected:
 	int				_itemsPerRow;
 	int				_firstVisibleItem;
 	int				_lastVisibleItem;
-	GridItemTray	*_tray;
 	bool			_isGridInvalid;
 
 	int				_scrollWindowPaddingX;




More information about the Scummvm-git-logs mailing list