# HG changeset patch # User John W. Eaton # Date 1571894150 14400 # Node ID 5189bfa8ad2a60ea07728be7577379837ac42d82 # Parent 35f9ffb13fd6d918f613ccdd17247a071853bf54 eliminate unnecessary use of pointers * dialog.h, dialog.cc (QUIWidgetCreator::m_string_list, QUIWidgetCreator::m_list_index, QUIWidgetCreator::m_path_name): Use objects instead of pointers. Change all uses. (QUIWidgetCreator::~QUIWidgetCreator): Explicitly use default dtor. (QUIWidgetCreator::get_list_index, QUIWidgetCreator::get_string_list, QUIWidgetCreator::get_dialog_path): Return value, not const pointer. Change all uses. diff -r 35f9ffb13fd6 -r 5189bfa8ad2a libgui/src/dialog.cc --- a/libgui/src/dialog.cc Wed Oct 23 12:50:42 2019 -0700 +++ b/libgui/src/dialog.cc Thu Oct 24 01:15:50 2019 -0400 @@ -48,17 +48,9 @@ QUIWidgetCreator::QUIWidgetCreator (void) : QObject (), m_dialog_result (-1), m_dialog_button (), - m_string_list (new QStringList ()), m_list_index (new QIntList ()), - m_path_name (new QString ()) + m_string_list (), m_list_index (), m_path_name () { } - QUIWidgetCreator::~QUIWidgetCreator (void) - { - delete m_string_list; - delete m_list_index; - delete m_path_name; - } - QString QUIWidgetCreator::rm_amp (const QString& text) { QString text_wo_amp = text; @@ -102,7 +94,7 @@ lock (); // Store the value so that builtin functions can retrieve. - *m_list_index = selected; + m_list_index = selected; m_dialog_result = button_pressed; unlock (); @@ -118,7 +110,7 @@ lock (); // Store the value so that builtin functions can retrieve. - *m_string_list = input; + m_string_list = input; m_dialog_result = button_pressed; unlock (); @@ -135,9 +127,9 @@ lock (); // Store the value so that builtin functions can retrieve. - *m_string_list = files; + m_string_list = files; m_dialog_result = filterindex; - *m_path_name = path; + m_path_name = path; unlock (); diff -r 35f9ffb13fd6 -r 5189bfa8ad2a libgui/src/dialog.h --- a/libgui/src/dialog.h Wed Oct 23 12:50:42 2019 -0700 +++ b/libgui/src/dialog.h Thu Oct 24 01:15:50 2019 -0400 @@ -50,7 +50,7 @@ QUIWidgetCreator (void); - ~QUIWidgetCreator (void); + ~QUIWidgetCreator (void) = default; public: @@ -94,7 +94,7 @@ return true; }; - const QIntList * get_list_index (void) { return m_list_index; } + QIntList get_list_index (void) const { return m_list_index; } bool signal_inputlayout (const QStringList& prompt, const QString& title, const QFloatList& nr, const QFloatList& nc, @@ -108,7 +108,7 @@ return true; }; - const QStringList * get_string_list (void) { return m_string_list; } + QStringList get_string_list (void) const { return m_string_list; } bool signal_filedialog (const QStringList& filters, const QString& title, const QString& filename, const QString& dirname, @@ -118,7 +118,7 @@ return true; } - const QString * get_dialog_path (void) { return m_path_name; } + QString get_dialog_path (void) const { return m_path_name; } void lock (void) { m_mutex.lock (); } void wait (void) { m_waitcondition.wait (&m_mutex); } @@ -162,10 +162,10 @@ // The list could conceivably be big. Not sure how things are // stored internally, so keep off of the stack. - QStringList *m_string_list; - QIntList *m_list_index; + QStringList m_string_list; + QIntList m_list_index; - QString *m_path_name; + QString m_path_name; // GUI objects cannot be accessed in the non-GUI thread. However, // signals can be sent to slots across threads with proper diff -r 35f9ffb13fd6 -r 5189bfa8ad2a libgui/src/qt-interpreter-events.cc --- a/libgui/src/qt-interpreter-events.cc Wed Oct 23 12:50:42 2019 -0700 +++ b/libgui/src/qt-interpreter-events.cc Thu Oct 24 01:15:50 2019 -0400 @@ -134,12 +134,12 @@ // The GUI has sent a signal and the thread has been awakened. // Add all the file dialog results to a string list. - const QStringList *inputLine = uiwidget_creator.get_string_list (); + QStringList inputLine = uiwidget_creator.get_string_list (); - for (auto it = inputLine->begin (); it != inputLine->end (); it++) + for (auto it = inputLine.begin (); it != inputLine.end (); it++) retval.push_back (it->toStdString ()); - retval.push_back (uiwidget_creator.get_dialog_path ()->toStdString ()); + retval.push_back (uiwidget_creator.get_dialog_path ().toStdString ()); retval.push_back ((QString ("%1").arg (uiwidget_creator.get_dialog_result ())).toStdString ()); uiwidget_creator.unlock (); @@ -170,11 +170,11 @@ // The GUI has sent a signal and the thread has been awakened. - const QStringList *inputLine = uiwidget_creator.get_string_list (); + QStringList inputLine = uiwidget_creator.get_string_list (); uiwidget_creator.unlock (); - for (auto it = inputLine->begin (); it != inputLine->end (); it++) + for (auto it = inputLine.begin (); it != inputLine.end (); it++) retval.push_back (it->toStdString ()); return retval; @@ -207,12 +207,12 @@ // The GUI has sent a signal and the thread has been awakened. - const QIntList *selected = uiwidget_creator.get_list_index (); + QIntList selected = uiwidget_creator.get_list_index (); int ok = uiwidget_creator.get_dialog_result (); uiwidget_creator.unlock (); - return std::pair, int> (selected->toStdList (), ok); + return std::pair, int> (selected.toStdList (), ok); } std::string