Fix crash.
Valentina crashes when a user uses a tool and select button Cancel to close a tool dialog. --HG-- branch : release
This commit is contained in:
parent
720366657f
commit
d354b99149
|
@ -660,32 +660,18 @@ void MainWindow::ClosedDialogWithApply(int result, VMainGraphicsScene *scene)
|
||||||
SCASSERT(not dialogTool.isNull())
|
SCASSERT(not dialogTool.isNull())
|
||||||
if (result == QDialog::Accepted)
|
if (result == QDialog::Accepted)
|
||||||
{
|
{
|
||||||
// Only create tool if not already created with apply
|
ApplyDialog<DrawTool>(scene);
|
||||||
if (dialogTool->GetAssociatedTool() == nullptr)
|
|
||||||
{
|
|
||||||
SCASSERT(scene != nullptr)
|
|
||||||
|
|
||||||
dialogTool->SetAssociatedTool(DrawTool::Create(dialogTool, scene, doc, pattern));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{ // Or update associated tool with data
|
|
||||||
DrawTool * vtool= qobject_cast<DrawTool *>(dialogTool->GetAssociatedTool());
|
|
||||||
SCASSERT(vtool != nullptr)
|
|
||||||
vtool->FullUpdateFromGuiApply();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
SCASSERT(not dialogTool.isNull())
|
// If before Cancel was used Apply we have an item
|
||||||
QGraphicsItem *tool = dynamic_cast<QGraphicsItem *>(dialogTool->GetAssociatedTool());
|
DrawTool *vtool = qobject_cast<DrawTool *>(dialogTool->GetAssociatedTool());// Don't check for nullptr here
|
||||||
SCASSERT(tool != nullptr)
|
|
||||||
ui->view->itemClicked(tool);
|
|
||||||
if (dialogTool->GetAssociatedTool() != nullptr)
|
if (dialogTool->GetAssociatedTool() != nullptr)
|
||||||
{
|
{
|
||||||
DrawTool *vtool= qobject_cast<DrawTool *>(dialogTool->GetAssociatedTool());
|
|
||||||
SCASSERT(vtool != nullptr)
|
SCASSERT(vtool != nullptr)
|
||||||
vtool->DialogLinkDestroy();
|
vtool->DialogLinkDestroy();
|
||||||
connect(vtool, &DrawTool::ToolTip, this, &MainWindow::ShowToolTip);
|
connect(vtool, &DrawTool::ToolTip, this, &MainWindow::ShowToolTip);
|
||||||
}
|
}
|
||||||
ArrowTool();
|
ArrowTool();
|
||||||
|
ui->view->itemClicked(vtool);// Don't check for nullptr here
|
||||||
// If insert not to the end of file call lite parse
|
// If insert not to the end of file call lite parse
|
||||||
if (doc->getCursor() > 0)
|
if (doc->getCursor() > 0)
|
||||||
{
|
{
|
||||||
|
@ -715,7 +701,7 @@ void MainWindow::ApplyDialog(VMainGraphicsScene *scene)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ // Or update associated tool with data
|
{ // Or update associated tool with data
|
||||||
DrawTool * vtool= qobject_cast<DrawTool *>(dialogTool->GetAssociatedTool());
|
DrawTool * vtool = qobject_cast<DrawTool *>(dialogTool->GetAssociatedTool());
|
||||||
SCASSERT(vtool != nullptr)
|
SCASSERT(vtool != nullptr)
|
||||||
vtool->FullUpdateFromGuiApply();
|
vtool->FullUpdateFromGuiApply();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user