From b47c90f0e0de420f3c78bca4e2a8394b25aba3da Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Thu, 24 Aug 2017 20:00:39 +0800 Subject: [PATCH 1/2] Setup parent ownership to avoid memory leak --- src/gui/properties/speedwidget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/properties/speedwidget.cpp b/src/gui/properties/speedwidget.cpp index daba84043..83013d981 100644 --- a/src/gui/properties/speedwidget.cpp +++ b/src/gui/properties/speedwidget.cpp @@ -87,7 +87,7 @@ SpeedWidget::SpeedWidget(PropertiesWidget *parent) m_graphsMenu->addAction(tr("Tracker Download")); m_graphsMenuActions = m_graphsMenu->actions(); - m_graphsSignalMapper = new QSignalMapper(); + m_graphsSignalMapper = new QSignalMapper(this); for (int id = SpeedPlotView::UP; id < SpeedPlotView::NB_GRAPHS; ++id) { QAction *action = m_graphsMenuActions.at(id); From ccd3b305c2c163789ec63a588e38ec4fa5efef4c Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Thu, 24 Aug 2017 20:12:17 +0800 Subject: [PATCH 2/2] Use Qt5 connect syntax --- src/gui/properties/speedwidget.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/gui/properties/speedwidget.cpp b/src/gui/properties/speedwidget.cpp index 83013d981..c0e63347f 100644 --- a/src/gui/properties/speedwidget.cpp +++ b/src/gui/properties/speedwidget.cpp @@ -72,7 +72,8 @@ SpeedWidget::SpeedWidget(PropertiesWidget *parent) m_periodCombobox->addItem(tr("30 Minutes")); m_periodCombobox->addItem(tr("6 Hours")); - connect(m_periodCombobox, SIGNAL(currentIndexChanged(int)), this, SLOT(onPeriodChange(int))); + connect(m_periodCombobox, static_cast(&QComboBox::currentIndexChanged) + , this, &SpeedWidget::onPeriodChange); m_graphsMenu = new QMenu(this); m_graphsMenu->addAction(tr("Total Upload")); @@ -93,10 +94,12 @@ SpeedWidget::SpeedWidget(PropertiesWidget *parent) QAction *action = m_graphsMenuActions.at(id); action->setCheckable(true); action->setChecked(true); - connect(action, SIGNAL(changed()), m_graphsSignalMapper, SLOT(map())); + connect(action, &QAction::changed, m_graphsSignalMapper + , static_cast(&QSignalMapper::map)); m_graphsSignalMapper->setMapping(action, id); } - connect(m_graphsSignalMapper, SIGNAL(mapped(int)), this, SLOT(onGraphChange(int))); + connect(m_graphsSignalMapper, static_cast(&QSignalMapper::mapped) + , this, &SpeedWidget::onGraphChange); m_graphsButton = new ComboBoxMenuButton(this, m_graphsMenu); m_graphsButton->addItem(tr("Select Graphs"));