Merge pull request #17782 from wwmayer/issue_17770

Unhandled std exception dragging Cylindrical joint
This commit is contained in:
Yorik van Havre
2024-11-11 17:56:04 +01:00
committed by GitHub
4 changed files with 33 additions and 12 deletions

View File

@@ -342,6 +342,17 @@ bool ViewProviderAssembly::keyPressed(bool pressed, int key)
}
bool ViewProviderAssembly::mouseMove(const SbVec2s& cursorPos, Gui::View3DInventorViewer* viewer)
{
try {
return tryMouseMove(cursorPos, viewer);
}
catch (const Base::Exception& e) {
Base::Console().Warning("%s\n", e.what());
return false;
}
}
bool ViewProviderAssembly::tryMouseMove(const SbVec2s& cursorPos, Gui::View3DInventorViewer* viewer)
{
if (!isInEditMode()) {
return false;
@@ -819,6 +830,16 @@ ViewProviderAssembly::DragMode ViewProviderAssembly::findDragMode()
}
void ViewProviderAssembly::initMove(const SbVec2s& cursorPos, Gui::View3DInventorViewer* viewer)
{
try {
tryInitMove(cursorPos, viewer);
}
catch (const Base::Exception& e) {
Base::Console().Warning("%s\n", e.what());
}
}
void ViewProviderAssembly::tryInitMove(const SbVec2s& cursorPos, Gui::View3DInventorViewer* viewer)
{
dragMode = findDragMode();
if (dragMode == DragMode::None) {

View File

@@ -130,7 +130,7 @@ public:
/// is called when the Provider is in edit and a key event ocours. Only ESC ends edit.
bool keyPressed(bool pressed, int key) override;
/// is called when the provider is in edit and the mouse is moved
bool mouseMove(const SbVec2s& pos, Gui::View3DInventorViewer* viewer) override;
bool mouseMove(const SbVec2s& cursorPos, Gui::View3DInventorViewer* viewer) override;
/// is called when the Provider is in edit and the mouse is clicked
bool mouseButtonPressed(int Button,
bool pressed,
@@ -226,6 +226,10 @@ public:
SoSwitch* asmDraggerSwitch = nullptr;
SoFieldSensor* translationSensor = nullptr;
SoFieldSensor* rotationSensor = nullptr;
private:
bool tryMouseMove(const SbVec2s& cursorPos, Gui::View3DInventorViewer* viewer);
void tryInitMove(const SbVec2s& cursorPos, Gui::View3DInventorViewer* viewer);
};
} // namespace AssemblyGui