Gui: Fix crash in measuring tool after an undo. (#25129)
Co-authored-by: Chris Hennes <chennes@pioneerlibrarysystem.org>
This commit is contained in:
@@ -163,6 +163,12 @@ TaskMeasure::TaskMeasure()
|
||||
// engage the selectionObserver
|
||||
attachSelection();
|
||||
|
||||
if (auto* doc = App::GetApplication().getActiveDocument()) {
|
||||
m_deletedConnection = doc->signalDeletedObject.connect([this](auto&& obj) {
|
||||
onObjectDeleted(obj);
|
||||
});
|
||||
}
|
||||
|
||||
if (!App::GetApplication().getActiveTransaction()) {
|
||||
App::GetApplication().setActiveTransaction("Add Measurement");
|
||||
}
|
||||
@@ -174,6 +180,7 @@ TaskMeasure::TaskMeasure()
|
||||
|
||||
TaskMeasure::~TaskMeasure()
|
||||
{
|
||||
m_deletedConnection.disconnect();
|
||||
Gui::Selection().setSelectionStyle(SelectionStyle::NormalSelection);
|
||||
detachSelection();
|
||||
}
|
||||
@@ -524,6 +531,13 @@ void TaskMeasure::quitMeasurement()
|
||||
}
|
||||
}
|
||||
|
||||
void TaskMeasure::onObjectDeleted(const App::DocumentObject& obj)
|
||||
{
|
||||
if (&obj == _mMeasureObject) {
|
||||
_mMeasureObject = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void TaskMeasure::setDeltaPossible(bool possible)
|
||||
{
|
||||
showDelta->setVisible(possible);
|
||||
|
||||
@@ -43,6 +43,8 @@
|
||||
#include <Gui/TaskView/TaskView.h>
|
||||
#include <Gui/Selection/Selection.h>
|
||||
|
||||
#include <boost/signals2/connection.hpp>
|
||||
|
||||
namespace MeasureGui
|
||||
{
|
||||
|
||||
@@ -74,6 +76,7 @@ private:
|
||||
void setupShortcuts(QWidget* parent);
|
||||
void tryUpdate();
|
||||
void onSelectionChanged(const Gui::SelectionChanges& msg) override;
|
||||
void onObjectDeleted(const App::DocumentObject& obj);
|
||||
void saveMeasurement();
|
||||
void quitMeasurement();
|
||||
|
||||
@@ -87,6 +90,8 @@ private:
|
||||
QAction* newMeasurementBehaviourAction {nullptr};
|
||||
QToolButton* mSettings {nullptr};
|
||||
|
||||
boost::signals2::connection m_deletedConnection;
|
||||
|
||||
void removeObject();
|
||||
void onModeChanged(int index);
|
||||
void showDeltaChanged(int checkState);
|
||||
|
||||
Reference in New Issue
Block a user