Fix segfault on bad input
This commit is contained in:
parent
657264ad49
commit
3797f7ebc3
|
@ -70,6 +70,7 @@ TaskSectionView::TaskSectionView(TechDraw::DrawViewPart* base, TechDraw::DrawVie
|
||||||
connect(ui->pbReset, SIGNAL(clicked(bool)),
|
connect(ui->pbReset, SIGNAL(clicked(bool)),
|
||||||
this, SLOT(onResetClicked(bool)));
|
this, SLOT(onResetClicked(bool)));
|
||||||
|
|
||||||
|
sectionDir = "unset";
|
||||||
saveInitialValues();
|
saveInitialValues();
|
||||||
resetValues();
|
resetValues();
|
||||||
}
|
}
|
||||||
|
@ -97,6 +98,7 @@ void TaskSectionView::resetValues()
|
||||||
checkAll(false);
|
checkAll(false);
|
||||||
enableAll(true);
|
enableAll(true);
|
||||||
|
|
||||||
|
sectionDir = "unset";
|
||||||
sectionProjDir = saveSectionProjDir;
|
sectionProjDir = saveSectionProjDir;
|
||||||
sectionNormal = saveSectionNormal;
|
sectionNormal = saveSectionNormal;
|
||||||
|
|
||||||
|
@ -114,8 +116,9 @@ void TaskSectionView::resetValues()
|
||||||
}
|
}
|
||||||
|
|
||||||
//calculate good starting points from base view and push buttons
|
//calculate good starting points from base view and push buttons
|
||||||
void TaskSectionView::calcValues()
|
bool TaskSectionView::calcValues()
|
||||||
{
|
{
|
||||||
|
bool result = true;
|
||||||
Base::Vector3d stdX(1.0,0.0,0.0);
|
Base::Vector3d stdX(1.0,0.0,0.0);
|
||||||
Base::Vector3d stdY(0.0,1.0,0.0);
|
Base::Vector3d stdY(0.0,1.0,0.0);
|
||||||
Base::Vector3d stdZ(0.0,0.0,1.0);
|
Base::Vector3d stdZ(0.0,0.0,1.0);
|
||||||
|
@ -165,25 +168,32 @@ void TaskSectionView::calcValues()
|
||||||
sectionProjDir = -1.0 * stdX;
|
sectionProjDir = -1.0 * stdX;
|
||||||
sectionNormal = -1.0 * stdX;
|
sectionNormal = -1.0 * stdX;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
Base::Console().Message("Select a direction\n");
|
||||||
|
result = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (result) {
|
||||||
ui->leNormal->setText(formatVector(sectionNormal));
|
ui->leNormal->setText(formatVector(sectionNormal));
|
||||||
ui->leProjDir->setText(formatVector(sectionProjDir));
|
ui->leProjDir->setText(formatVector(sectionProjDir));
|
||||||
|
|
||||||
Base::Console().Message("Press Reset, OK or Cancel to continue\n");
|
Base::Console().Message("Press Reset, OK or Cancel to continue\n");
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
//move values from screen to DocObjs
|
//move values from screen to DocObjs
|
||||||
void TaskSectionView::updateValues()
|
void TaskSectionView::updateValues()
|
||||||
{
|
{
|
||||||
|
if (strcmp(sectionDir,"unset") != 0) {
|
||||||
m_section->SectionDirection.setValue(sectionDir);
|
m_section->SectionDirection.setValue(sectionDir);
|
||||||
|
}
|
||||||
m_section->Direction.setValue(sectionProjDir);
|
m_section->Direction.setValue(sectionProjDir);
|
||||||
m_section->SectionNormal.setValue(sectionNormal);
|
m_section->SectionNormal.setValue(sectionNormal);
|
||||||
Base::Vector3d origin(ui->sb_OrgX->value().getValue(),
|
Base::Vector3d origin(ui->sb_OrgX->value().getValue(),
|
||||||
ui->sb_OrgY->value().getValue(),
|
ui->sb_OrgY->value().getValue(),
|
||||||
ui->sb_OrgZ->value().getValue());
|
ui->sb_OrgZ->value().getValue());
|
||||||
m_section->SectionOrigin.setValue(origin);
|
m_section->SectionOrigin.setValue(origin);
|
||||||
m_section->SectionDirection.setValue(sectionDir);
|
|
||||||
m_section->SectionSymbol.setValue(ui->leSymbol->text().toUtf8().constData());
|
m_section->SectionSymbol.setValue(ui->leSymbol->text().toUtf8().constData());
|
||||||
|
|
||||||
m_base->touch();
|
m_base->touch();
|
||||||
|
@ -206,8 +216,9 @@ void TaskSectionView::turnOnUp()
|
||||||
ui->pb_Up->setChecked(true);
|
ui->pb_Up->setChecked(true);
|
||||||
ui->pb_Up->setEnabled(true);
|
ui->pb_Up->setEnabled(true);
|
||||||
blockButtons(false);
|
blockButtons(false);
|
||||||
calcValues();
|
if (calcValues()) {
|
||||||
updateValues();
|
updateValues();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TaskSectionView::turnOnDown()
|
void TaskSectionView::turnOnDown()
|
||||||
|
@ -218,8 +229,9 @@ void TaskSectionView::turnOnDown()
|
||||||
ui->pb_Down->setChecked(true);
|
ui->pb_Down->setChecked(true);
|
||||||
ui->pb_Down->setEnabled(true);
|
ui->pb_Down->setEnabled(true);
|
||||||
blockButtons(false);
|
blockButtons(false);
|
||||||
calcValues();
|
if (calcValues()) {
|
||||||
updateValues();
|
updateValues();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TaskSectionView::turnOnLeft()
|
void TaskSectionView::turnOnLeft()
|
||||||
|
@ -230,8 +242,9 @@ void TaskSectionView::turnOnLeft()
|
||||||
ui->pb_Left->setChecked(true);
|
ui->pb_Left->setChecked(true);
|
||||||
ui->pb_Left->setEnabled(true);
|
ui->pb_Left->setEnabled(true);
|
||||||
blockButtons(false);
|
blockButtons(false);
|
||||||
calcValues();
|
if (calcValues()) {
|
||||||
updateValues();
|
updateValues();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TaskSectionView::turnOnRight()
|
void TaskSectionView::turnOnRight()
|
||||||
|
@ -242,8 +255,9 @@ void TaskSectionView::turnOnRight()
|
||||||
ui->pb_Right->setChecked(true);
|
ui->pb_Right->setChecked(true);
|
||||||
ui->pb_Right->setEnabled(true);
|
ui->pb_Right->setEnabled(true);
|
||||||
blockButtons(false);
|
blockButtons(false);
|
||||||
calcValues();
|
if (calcValues()) {
|
||||||
updateValues();
|
updateValues();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TaskSectionView::checkAll(bool b)
|
void TaskSectionView::checkAll(bool b)
|
||||||
|
@ -302,8 +316,14 @@ void TaskSectionView::onResetClicked(bool b)
|
||||||
|
|
||||||
bool TaskSectionView::accept()
|
bool TaskSectionView::accept()
|
||||||
{
|
{
|
||||||
|
if (strcmp(sectionDir,"unset") != 0) {
|
||||||
updateValues();
|
updateValues();
|
||||||
return true;
|
return true;
|
||||||
|
} else {
|
||||||
|
Base::Console().Message("No direction selected!\n");
|
||||||
|
reject();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TaskSectionView::reject()
|
bool TaskSectionView::reject()
|
||||||
|
|
|
@ -66,7 +66,7 @@ protected:
|
||||||
void blockButtons(bool b);
|
void blockButtons(bool b);
|
||||||
void changeEvent(QEvent *e);
|
void changeEvent(QEvent *e);
|
||||||
void resetValues();
|
void resetValues();
|
||||||
void calcValues();
|
bool calcValues();
|
||||||
void saveInitialValues();
|
void saveInitialValues();
|
||||||
void updateValues();
|
void updateValues();
|
||||||
QString formatVector(Base::Vector3d v);
|
QString formatVector(Base::Vector3d v);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user