[TD]trap potential crash on app close

- avoid possible crash in TD dialogs if app closed
  while dialog in progress.
This commit is contained in:
wandererfan
2020-04-22 11:31:47 -04:00
committed by WandererFan
parent 0a3f7ae312
commit 0c57730cd2
3 changed files with 43 additions and 44 deletions

View File

@@ -125,7 +125,7 @@ TaskDetail::TaskDetail(TechDraw::DrawViewPart* baseFeat):
this, SLOT(onYEdit()));
connect(ui->qsbRadius, SIGNAL(editingFinished()),
this, SLOT(onRadiusEdit()));
connect(ui->aeReference, SIGNAL(editingFinished()),
connect(ui->leReference, SIGNAL(editingFinished()),
this, SLOT(onReferenceEdit()));
m_ghost = new QGIGhostHighlight();
@@ -198,7 +198,7 @@ TaskDetail::TaskDetail(TechDraw::DrawViewDetail* detailFeat):
this, SLOT(onYEdit()));
connect(ui->qsbRadius, SIGNAL(editingFinished()),
this, SLOT(onRadiusEdit()));
connect(ui->aeReference, SIGNAL(editingFinished()),
connect(ui->leReference, SIGNAL(editingFinished()),
this, SLOT(onReferenceEdit()));
m_ghost = new QGIGhostHighlight();
@@ -280,7 +280,7 @@ void TaskDetail::setUiFromFeat()
ui->qsbX->setValue(anchor.x);
ui->qsbY->setValue(anchor.y);
ui->qsbRadius->setValue(radius);
ui->aeReference->setText(ref);
ui->leReference->setText(ref);
}
//update ui point fields after tracker finishes
@@ -295,7 +295,7 @@ void TaskDetail::enableInputFields(bool b)
ui->qsbX->setEnabled(b);
ui->qsbY->setEnabled(b);
ui->qsbRadius->setEnabled(b);
ui->aeReference->setEnabled(b);
ui->leReference->setEnabled(b);
}
void TaskDetail::onXEdit()
@@ -315,7 +315,7 @@ void TaskDetail::onRadiusEdit()
void TaskDetail::onReferenceEdit()
{
updateDetail();
updateDetail(); //<<<<<
}
void TaskDetail::onDraggerClicked(bool b)
@@ -430,23 +430,29 @@ void TaskDetail::createDetail()
void TaskDetail::updateDetail()
{
// Base::Console().Message("TD::updateDetail()\n");
Gui::Command::openCommand("Update Detail");
double x = ui->qsbX->rawValue();
double y = ui->qsbY->rawValue();
Base::Vector3d temp(x, y, 0.0);
TechDraw::DrawViewDetail* detailFeat = getDetailFeat();
detailFeat->AnchorPoint.setValue(temp);
try {
Gui::Command::openCommand("Update Detail");
double x = ui->qsbX->rawValue();
double y = ui->qsbY->rawValue();
Base::Vector3d temp(x, y, 0.0);
TechDraw::DrawViewDetail* detailFeat = getDetailFeat();
detailFeat->AnchorPoint.setValue(temp);
double radius = ui->qsbRadius->rawValue();
detailFeat->Radius.setValue(radius);
QString qRef = ui->aeReference->text();
std::string ref = Base::Tools::toStdString(qRef);
detailFeat->Reference.setValue(ref);
double radius = ui->qsbRadius->rawValue();
detailFeat->Radius.setValue(radius);
QString qRef = ui->leReference->text();
std::string ref = Base::Tools::toStdString(qRef);
detailFeat->Reference.setValue(ref);
detailFeat->recomputeFeature();
getBaseFeat()->requestPaint();
Gui::Command::updateActive();
Gui::Command::commitCommand();
detailFeat->recomputeFeature();
getBaseFeat()->requestPaint();
Gui::Command::updateActive();
Gui::Command::commitCommand();
}
catch (...) {
//this is probably due to appl closing while dialog is still open
Base::Console().Error("Task Detail - detail feature update failed.\n");
}
}
//***** Getters ****************************************************************

View File

@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>304</width>
<height>244</height>
<height>253</height>
</rect>
</property>
<property name="sizePolicy">
@@ -214,13 +214,7 @@
</widget>
</item>
<item row="3" column="2">
<widget class="Gui::AccelLineEdit" name="aeReference">
<property name="toolTip">
<string>Detail identifier</string>
</property>
<property name="text">
<string>1</string>
</property>
<widget class="QLineEdit" name="leReference">
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
@@ -231,11 +225,6 @@
</layout>
</widget>
<customwidgets>
<customwidget>
<class>Gui::AccelLineEdit</class>
<extends>QLineEdit</extends>
<header>Gui/Widgets.h</header>
</customwidget>
<customwidget>
<class>Gui::QuantitySpinBox</class>
<extends>QWidget</extends>

View File

@@ -184,13 +184,15 @@ QGIView* ViewProviderDrawingView::getQView(void)
TechDraw::DrawView* dv = getViewObject();
if (dv) {
Gui::Document* guiDoc = Gui::Application::Instance->getDocument(getViewObject()->getDocument());
Gui::ViewProvider* vp = guiDoc->getViewProvider(getViewObject()->findParentPage());
ViewProviderPage* dvp = dynamic_cast<ViewProviderPage*>(vp);
if (dvp) {
if (dvp->getMDIViewPage()) {
if (dvp->getMDIViewPage()->getQGVPage()) {
qView = dynamic_cast<QGIView *>(dvp->getMDIViewPage()->
getQGVPage()->findQViewForDocObj(getViewObject()));
if (guiDoc != nullptr) {
Gui::ViewProvider* vp = guiDoc->getViewProvider(getViewObject()->findParentPage());
ViewProviderPage* dvp = dynamic_cast<ViewProviderPage*>(vp);
if (dvp) {
if (dvp->getMDIViewPage()) {
if (dvp->getMDIViewPage()->getQGVPage()) {
qView = dynamic_cast<QGIView *>(dvp->getMDIViewPage()->
getQGVPage()->findQViewForDocObj(getViewObject()));
}
}
}
}
@@ -249,10 +251,12 @@ MDIViewPage* ViewProviderDrawingView::getMDIViewPage() const
{
MDIViewPage* result = nullptr;
Gui::Document* guiDoc = Gui::Application::Instance->getDocument(getViewObject()->getDocument());
Gui::ViewProvider* vp = guiDoc->getViewProvider(getViewObject()->findParentPage()); //if not in page.views, !@#$%
ViewProviderPage* dvp = dynamic_cast<ViewProviderPage*>(vp);
if (dvp) {
result = dvp->getMDIViewPage();
if (guiDoc != nullptr) {
Gui::ViewProvider* vp = guiDoc->getViewProvider(getViewObject()->findParentPage());
ViewProviderPage* dvp = dynamic_cast<ViewProviderPage*>(vp);
if (dvp) {
result = dvp->getMDIViewPage();
}
}
return result;
}