Use QScopedPointer to prevent memory leaks.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2017-02-18 10:43:06 +02:00
parent 7b23e89237
commit 8f0f2399e2
7 changed files with 19 additions and 19 deletions

View File

@ -2234,11 +2234,11 @@ bool TMainWindow::MaybeSave()
return true;// Don't ask if file was created without modifications.
}
QMessageBox *messageBox = new QMessageBox(tr("Unsaved changes"),
tr("Measurements have been modified.\n"
"Do you want to save your changes?"),
QMessageBox::Warning, QMessageBox::Yes, QMessageBox::No,
QMessageBox::Cancel, this, Qt::Sheet);
QScopedPointer<QMessageBox> messageBox(new QMessageBox(tr("Unsaved changes"),
tr("Measurements have been modified.\n"
"Do you want to save your changes?"),
QMessageBox::Warning, QMessageBox::Yes, QMessageBox::No,
QMessageBox::Cancel, this, Qt::Sheet));
messageBox->setDefaultButton(QMessageBox::Yes);
messageBox->setEscapeButton(QMessageBox::Cancel);

View File

@ -183,7 +183,7 @@ void VWidgetDetails::ToggleSectionDetails(bool select)
//---------------------------------------------------------------------------------------------------------------------
void VWidgetDetails::ShowContextMenu(const QPoint &pos)
{
QMenu *menu = new QMenu(this);
QScopedPointer<QMenu> menu(new QMenu(this));
QAction *actionSelectAll = menu->addAction(tr("Select all"));
QAction *actionSelectNone = menu->addAction(tr("Select none"));

View File

@ -103,7 +103,7 @@ void VWidgetGroups::CtxMenu(const QPoint &pos)
item = ui->tableWidget->item(row, 0);
const quint32 id = item->data(Qt::UserRole).toUInt();
QMenu *menu = new QMenu(this);
QScopedPointer<QMenu> menu(new QMenu(this));
QAction *actionRename = menu->addAction(tr("Rename"));
QAction *actionDelete = menu->addAction(tr("Delete"));
QAction *selectedAction = menu->exec(ui->tableWidget->viewport()->mapToGlobal(pos));

View File

@ -3334,11 +3334,11 @@ bool MainWindow::MaybeSave()
{
if (this->isWindowModified() && guiEnabled)
{
QMessageBox *messageBox = new QMessageBox(tr("Unsaved changes"),
tr("The pattern has been modified.\n"
"Do you want to save your changes?"),
QMessageBox::Warning, QMessageBox::Yes, QMessageBox::No,
QMessageBox::Cancel, this, Qt::Sheet);
QScopedPointer<QMessageBox> messageBox(new QMessageBox(tr("Unsaved changes"),
tr("The pattern has been modified.\n"
"Do you want to save your changes?"),
QMessageBox::Warning, QMessageBox::Yes, QMessageBox::No,
QMessageBox::Cancel, this, Qt::Sheet));
messageBox->setDefaultButton(QMessageBox::Yes);
messageBox->setEscapeButton(QMessageBox::Cancel);

View File

@ -218,7 +218,7 @@ void DialogPiecePath::ShowContextMenu(const QPoint &pos)
return;
}
QMenu *menu = new QMenu(this);
QScopedPointer<QMenu> menu(new QMenu(this));
QListWidgetItem *rowItem = ui->listWidget->item(row);
SCASSERT(rowItem != nullptr);

View File

@ -482,7 +482,7 @@ void DialogSeamAllowance::ShowMainPathContextMenu(const QPoint &pos)
return;
}
QMenu *menu = new QMenu(this);
QScopedPointer<QMenu> menu(new QMenu(this));
QListWidgetItem *rowItem = ui->listWidgetMainPath->item(row);
SCASSERT(rowItem != nullptr);
@ -524,7 +524,7 @@ void DialogSeamAllowance::ShowCustomSAContextMenu(const QPoint &pos)
return;
}
QMenu *menu = new QMenu(this);
QScopedPointer<QMenu> menu(new QMenu(this));
QAction *actionOption = menu->addAction(QIcon::fromTheme("preferences-other"), tr("Options"));
QListWidgetItem *rowItem = ui->listWidgetCustomSA->item(row);
@ -574,7 +574,7 @@ void DialogSeamAllowance::ShowInternalPathsContextMenu(const QPoint &pos)
return;
}
QMenu *menu = new QMenu(this);
QScopedPointer<QMenu> menu(new QMenu(this));
QAction *actionOption = menu->addAction(QIcon::fromTheme("preferences-other"), tr("Options"));
QAction *actionDelete = menu->addAction(QIcon::fromTheme("edit-delete"), tr("Delete"));

View File

@ -1141,7 +1141,7 @@ void VToolSeamAllowance::InitInternalPaths(const VPiece &detail)
//---------------------------------------------------------------------------------------------------------------------
void VToolSeamAllowance::DeleteTool(bool ask)
{
DeletePiece *delDet = new DeletePiece(doc, id, VAbstractTool::data.GetPiece(id));
QScopedPointer<DeletePiece> delDet(new DeletePiece(doc, id, VAbstractTool::data.GetPiece(id)));
if (ask)
{
if (ConfirmDeletion() == QMessageBox::No)
@ -1149,7 +1149,7 @@ void VToolSeamAllowance::DeleteTool(bool ask)
return;
}
/* If UnionDetails tool delete detail no need emit FullParsing.*/
connect(delDet, &DeletePiece::NeedFullParsing, doc, &VAbstractPattern::NeedFullParsing);
connect(delDet.data(), &DeletePiece::NeedFullParsing, doc, &VAbstractPattern::NeedFullParsing);
}
// If UnionDetails tool delete the detail this object will be deleted only after full parse.
@ -1168,7 +1168,7 @@ void VToolSeamAllowance::DeleteTool(bool ask)
hide();// User shouldn't see this object
qApp->getUndoStack()->push(delDet);
qApp->getUndoStack()->push(delDet.take());
// Throw exception, this will help prevent case when we forget to immediately quit function.
VExceptionToolWasDeleted e("Tool was used after deleting.");