Skip to content

Commit

Permalink
[TD]prevent fail on delete with open dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
WandererFan authored and davesrocketshop committed Mar 16, 2024
1 parent d2e27b3 commit f98a91f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/Mod/TechDraw/Gui/ViewProviderDimension.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,14 @@
# include <QMenu>
#endif

#include <QMessageBox>

#include <Base/Parameter.h>
#include <App/Application.h>
#include <App/DocumentObject.h>
#include <Gui/ActionFunction.h>
#include <Gui/Control.h>
#include <Gui/MainWindow.h>

#include <Mod/TechDraw/App/LineGroup.h>
#include <Mod/TechDraw/App/LandmarkDimension.h>
Expand Down Expand Up @@ -283,3 +286,23 @@ bool ViewProviderDimension::canDelete(App::DocumentObject *obj) const
Q_UNUSED(obj)
return true;
}

bool ViewProviderDimension::onDelete(const std::vector<std::string> & parms)
{
Q_UNUSED(parms)
// Base::Console().Message("VPB::onDelete() - parms: %d\n", parms.size());
auto dlg = Gui::Control().activeDialog();
auto ourDlg = dynamic_cast<TaskDlgDimension*>(dlg);
if (ourDlg) {
QString bodyMessage;
QTextStream bodyMessageStream(&bodyMessage);
bodyMessageStream << qApp->translate("TaskDimension",
"You cannot delete this dimension now because\nthere is an open task dialog.");
QMessageBox::warning(Gui::getMainWindow(),
qApp->translate("TaskDimension", "Can Not Delete"), bodyMessage,
QMessageBox::Ok);
return false;
}
return true;
}

2 changes: 2 additions & 0 deletions src/Mod/TechDraw/Gui/ViewProviderDimension.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ class TechDrawGuiExport ViewProviderDimension : public ViewProviderDrawingView
void setupContextMenu(QMenu*, QObject*, const char*) override;
bool setEdit(int ModNum) override;
bool doubleClicked() override;
bool onDelete(const std::vector<std::string> & parms) override;


TechDraw::DrawViewDimension* getViewObject() const override;

Expand Down

0 comments on commit f98a91f

Please sign in to comment.