Use QScopedPointer to prevent memory leaks.
--HG-- branch : develop
This commit is contained in:
parent
7b23e89237
commit
8f0f2399e2
|
@ -2234,11 +2234,11 @@ bool TMainWindow::MaybeSave()
|
||||||
return true;// Don't ask if file was created without modifications.
|
return true;// Don't ask if file was created without modifications.
|
||||||
}
|
}
|
||||||
|
|
||||||
QMessageBox *messageBox = new QMessageBox(tr("Unsaved changes"),
|
QScopedPointer<QMessageBox> messageBox(new QMessageBox(tr("Unsaved changes"),
|
||||||
tr("Measurements have been modified.\n"
|
tr("Measurements have been modified.\n"
|
||||||
"Do you want to save your changes?"),
|
"Do you want to save your changes?"),
|
||||||
QMessageBox::Warning, QMessageBox::Yes, QMessageBox::No,
|
QMessageBox::Warning, QMessageBox::Yes, QMessageBox::No,
|
||||||
QMessageBox::Cancel, this, Qt::Sheet);
|
QMessageBox::Cancel, this, Qt::Sheet));
|
||||||
|
|
||||||
messageBox->setDefaultButton(QMessageBox::Yes);
|
messageBox->setDefaultButton(QMessageBox::Yes);
|
||||||
messageBox->setEscapeButton(QMessageBox::Cancel);
|
messageBox->setEscapeButton(QMessageBox::Cancel);
|
||||||
|
|
|
@ -183,7 +183,7 @@ void VWidgetDetails::ToggleSectionDetails(bool select)
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VWidgetDetails::ShowContextMenu(const QPoint &pos)
|
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 *actionSelectAll = menu->addAction(tr("Select all"));
|
||||||
QAction *actionSelectNone = menu->addAction(tr("Select none"));
|
QAction *actionSelectNone = menu->addAction(tr("Select none"));
|
||||||
|
|
||||||
|
|
|
@ -103,7 +103,7 @@ void VWidgetGroups::CtxMenu(const QPoint &pos)
|
||||||
item = ui->tableWidget->item(row, 0);
|
item = ui->tableWidget->item(row, 0);
|
||||||
const quint32 id = item->data(Qt::UserRole).toUInt();
|
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 *actionRename = menu->addAction(tr("Rename"));
|
||||||
QAction *actionDelete = menu->addAction(tr("Delete"));
|
QAction *actionDelete = menu->addAction(tr("Delete"));
|
||||||
QAction *selectedAction = menu->exec(ui->tableWidget->viewport()->mapToGlobal(pos));
|
QAction *selectedAction = menu->exec(ui->tableWidget->viewport()->mapToGlobal(pos));
|
||||||
|
|
|
@ -3334,11 +3334,11 @@ bool MainWindow::MaybeSave()
|
||||||
{
|
{
|
||||||
if (this->isWindowModified() && guiEnabled)
|
if (this->isWindowModified() && guiEnabled)
|
||||||
{
|
{
|
||||||
QMessageBox *messageBox = new QMessageBox(tr("Unsaved changes"),
|
QScopedPointer<QMessageBox> messageBox(new QMessageBox(tr("Unsaved changes"),
|
||||||
tr("The pattern has been modified.\n"
|
tr("The pattern has been modified.\n"
|
||||||
"Do you want to save your changes?"),
|
"Do you want to save your changes?"),
|
||||||
QMessageBox::Warning, QMessageBox::Yes, QMessageBox::No,
|
QMessageBox::Warning, QMessageBox::Yes, QMessageBox::No,
|
||||||
QMessageBox::Cancel, this, Qt::Sheet);
|
QMessageBox::Cancel, this, Qt::Sheet));
|
||||||
|
|
||||||
messageBox->setDefaultButton(QMessageBox::Yes);
|
messageBox->setDefaultButton(QMessageBox::Yes);
|
||||||
messageBox->setEscapeButton(QMessageBox::Cancel);
|
messageBox->setEscapeButton(QMessageBox::Cancel);
|
||||||
|
|
|
@ -218,7 +218,7 @@ void DialogPiecePath::ShowContextMenu(const QPoint &pos)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QMenu *menu = new QMenu(this);
|
QScopedPointer<QMenu> menu(new QMenu(this));
|
||||||
|
|
||||||
QListWidgetItem *rowItem = ui->listWidget->item(row);
|
QListWidgetItem *rowItem = ui->listWidget->item(row);
|
||||||
SCASSERT(rowItem != nullptr);
|
SCASSERT(rowItem != nullptr);
|
||||||
|
|
|
@ -482,7 +482,7 @@ void DialogSeamAllowance::ShowMainPathContextMenu(const QPoint &pos)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QMenu *menu = new QMenu(this);
|
QScopedPointer<QMenu> menu(new QMenu(this));
|
||||||
|
|
||||||
QListWidgetItem *rowItem = ui->listWidgetMainPath->item(row);
|
QListWidgetItem *rowItem = ui->listWidgetMainPath->item(row);
|
||||||
SCASSERT(rowItem != nullptr);
|
SCASSERT(rowItem != nullptr);
|
||||||
|
@ -524,7 +524,7 @@ void DialogSeamAllowance::ShowCustomSAContextMenu(const QPoint &pos)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QMenu *menu = new QMenu(this);
|
QScopedPointer<QMenu> menu(new QMenu(this));
|
||||||
QAction *actionOption = menu->addAction(QIcon::fromTheme("preferences-other"), tr("Options"));
|
QAction *actionOption = menu->addAction(QIcon::fromTheme("preferences-other"), tr("Options"));
|
||||||
|
|
||||||
QListWidgetItem *rowItem = ui->listWidgetCustomSA->item(row);
|
QListWidgetItem *rowItem = ui->listWidgetCustomSA->item(row);
|
||||||
|
@ -574,7 +574,7 @@ void DialogSeamAllowance::ShowInternalPathsContextMenu(const QPoint &pos)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QMenu *menu = new QMenu(this);
|
QScopedPointer<QMenu> menu(new QMenu(this));
|
||||||
QAction *actionOption = menu->addAction(QIcon::fromTheme("preferences-other"), tr("Options"));
|
QAction *actionOption = menu->addAction(QIcon::fromTheme("preferences-other"), tr("Options"));
|
||||||
QAction *actionDelete = menu->addAction(QIcon::fromTheme("edit-delete"), tr("Delete"));
|
QAction *actionDelete = menu->addAction(QIcon::fromTheme("edit-delete"), tr("Delete"));
|
||||||
|
|
||||||
|
|
|
@ -1141,7 +1141,7 @@ void VToolSeamAllowance::InitInternalPaths(const VPiece &detail)
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VToolSeamAllowance::DeleteTool(bool ask)
|
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 (ask)
|
||||||
{
|
{
|
||||||
if (ConfirmDeletion() == QMessageBox::No)
|
if (ConfirmDeletion() == QMessageBox::No)
|
||||||
|
@ -1149,7 +1149,7 @@ void VToolSeamAllowance::DeleteTool(bool ask)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/* If UnionDetails tool delete detail no need emit FullParsing.*/
|
/* 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.
|
// 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
|
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.
|
// Throw exception, this will help prevent case when we forget to immediately quit function.
|
||||||
VExceptionToolWasDeleted e("Tool was used after deleting.");
|
VExceptionToolWasDeleted e("Tool was used after deleting.");
|
||||||
|
|
Loading…
Reference in New Issue
Block a user