# HG changeset patch # User John W. Eaton # Date 1460470207 14400 # Node ID e15d3387fc595a05b9d9845fe594b5e9292ea26f # Parent edd0ce03f548dee30ecba08650bbffc8dd09f8bb eliminate leak in ListDialog class (bug #47372) * dialog.h, dialog.cc (ListDialog::model): New data member. (ListDialog::ListDialog): Initialize class data member instead of storing pointer in local variable. (ListDialog::~ListDialog): New function. Delete model. diff -r edd0ce03f548 -r e15d3387fc59 libgui/src/dialog.cc --- a/libgui/src/dialog.cc Tue Apr 12 12:58:48 2016 +0100 +++ b/libgui/src/dialog.cc Tue Apr 12 10:10:07 2016 -0400 @@ -205,12 +205,8 @@ int wd, int ht, const QList& initial, const QString& title, const QStringList& prompt, const QString& ok_string, const QString& cancel_string) - : QDialog () + : QDialog (), model (new QStringListModel (list)) { - // Put the list of items into a model. Keep this off of the stack - // because this conceivably could be a very large list. - QAbstractItemModel *model = new QStringListModel (list); - QListView *view = new QListView; view->setModel (model); @@ -306,6 +302,10 @@ this, SLOT (item_double_clicked (const QModelIndex&))); } +ListDialog::~ListDialog (void) +{ + delete model; +} void ListDialog::buttonOk_clicked (void) diff -r edd0ce03f548 -r e15d3387fc59 libgui/src/dialog.h --- a/libgui/src/dialog.h Tue Apr 12 12:58:48 2016 +0100 +++ b/libgui/src/dialog.h Tue Apr 12 10:10:07 2016 -0400 @@ -199,6 +199,8 @@ const QString& name, const QStringList& prompt, const QString& ok_string, const QString& cancel_string); + ~ListDialog (void); + signals: void finish_selection (const QIntList&, int); @@ -212,6 +214,10 @@ void reject (void); void item_double_clicked (const QModelIndex&); + +private: + + QAbstractItemModel *model; };