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;
gradationSizes = nullptr;
}
if (not gradationHeightsLabel.isNull())
{
gradationHeightsLabel.clear();
}
if (not gradationSizesLabel.isNull())
{
gradationSizesLabel.clear();
}
if (qApp->patternType() == MeasurementsType::Standard)
{
const QStringList listHeights = VMeasurement::ListHeights(doc->GetGradationHeights(), 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()));
connect(gradationHeights, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
this, &MainWindow::ChangedHeight);
gradationSizes = SetGradationList(tr("Size: "), listSizes);
gradationSizesLabel = new QLabel(tr("Size: "), this);
gradationSizes = SetGradationList(gradationSizesLabel, listSizes);
SetDefaultSize(static_cast<int>(pattern->size()));
connect(gradationSizes, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
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);
comboBox->addItems(list);

View file

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