Fixed memory leaks for labels

--HG--
branch : develop
This commit is contained in:
Valentina Zhuravska 2015-09-17 03:46:05 +03:00
parent 4100b0f9b1
commit 07f928cba7
2 changed files with 18 additions and 5 deletions

View File

@ -1199,18 +1199,28 @@ void MainWindow::ToolBarOption()
delete gradationSizes; delete gradationSizes;
gradationSizes = nullptr; gradationSizes = nullptr;
} }
if (not gradationHeightsLabel.isNull())
{
gradationHeightsLabel.clear();
}
if (not gradationSizesLabel.isNull())
{
gradationSizesLabel.clear();
}
if (qApp->patternType() == MeasurementsType::Standard) if (qApp->patternType() == MeasurementsType::Standard)
{ {
const QStringList listHeights = VMeasurement::ListHeights(doc->GetGradationHeights(), qApp->patternUnit()); const QStringList listHeights = VMeasurement::ListHeights(doc->GetGradationHeights(), qApp->patternUnit());
const QStringList listSizes = VMeasurement::ListSizes(doc->GetGradationSizes(), qApp->patternUnit()); const QStringList listSizes = VMeasurement::ListSizes(doc->GetGradationSizes(), qApp->patternUnit());
gradationHeights = SetGradationList(tr("Height: "), listHeights); gradationHeightsLabel = new QLabel(tr("Height: "), this);
gradationHeights = SetGradationList(gradationHeightsLabel, listHeights);
SetDefaultHeight(static_cast<int>(pattern->height())); SetDefaultHeight(static_cast<int>(pattern->height()));
connect(gradationHeights, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged), connect(gradationHeights, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
this, &MainWindow::ChangedHeight); this, &MainWindow::ChangedHeight);
gradationSizes = SetGradationList(tr("Size: "), listSizes); gradationSizesLabel = new QLabel(tr("Size: "), this);
gradationSizes = SetGradationList(gradationSizesLabel, listSizes);
SetDefaultSize(static_cast<int>(pattern->size())); SetDefaultSize(static_cast<int>(pattern->size()));
connect(gradationSizes, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged), connect(gradationSizes, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
this, &MainWindow::ChangedSize); this, &MainWindow::ChangedSize);
@ -1223,9 +1233,9 @@ void MainWindow::ToolBarOption()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QComboBox *MainWindow::SetGradationList(const QString &label, const QStringList &list) QComboBox *MainWindow::SetGradationList(QPointer<QLabel> &label, const QStringList &list)
{ {
ui->toolBarOption->addWidget(new QLabel(label, this)); ui->toolBarOption->addWidget(label.data());
QComboBox *comboBox = new QComboBox(this); QComboBox *comboBox = new QComboBox(this);
comboBox->addItems(list); comboBox->addItems(list);

View File

@ -38,6 +38,7 @@
#include "tools/drawTools/drawtools.h" #include "tools/drawTools/drawtools.h"
#include "core/vcmdexport.h" #include "core/vcmdexport.h"
#include <QLockFile> #include <QLockFile>
#include <QPointer>
#include <QFileSystemWatcher> #include <QFileSystemWatcher>
@ -229,6 +230,8 @@ private:
bool guiEnabled; bool guiEnabled;
QComboBox *gradationHeights; QComboBox *gradationHeights;
QComboBox *gradationSizes; QComboBox *gradationSizes;
QPointer<QLabel> gradationHeightsLabel;
QPointer<QLabel> gradationSizesLabel;
VToolOptionsPropertyBrowser *toolOptions; VToolOptionsPropertyBrowser *toolOptions;
#if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0) #if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
QLockFile *lock; QLockFile *lock;
@ -276,7 +279,7 @@ private:
void InitAutoSave(); void InitAutoSave();
QString PatternPieceName(const QString &text); QString PatternPieceName(const QString &text);
QString CheckPathToMeasurements(const QString &patternPath, const QString &path); QString CheckPathToMeasurements(const QString &patternPath, const QString &path);
QComboBox *SetGradationList(const QString &label, const QStringList &list); QComboBox *SetGradationList(QPointer<QLabel> &label, const QStringList &list);
void ChangePP(int index, bool zoomBestFit = true); void ChangePP(int index, bool zoomBestFit = true);
/** /**
* @brief EndVisualization try show dialog after and working with tool visualization. * @brief EndVisualization try show dialog after and working with tool visualization.