Commit Graph

12 Commits

Author SHA1 Message Date
Benjamin Nauck
e5a81b9f44 Gui: Refactor LCS fixes
* use early exit to highlight main execution path
* use `auto*` for pointer
* use getObject<T>() instead of casting result from getObject()
* remove empty updateData()
* rename origin to lcs in setTemporaryVisibility for clarity
2025-06-12 10:27:06 +02:00
wmayer
2a664ea7ab Gui: Fix crash when creating a LCS
This is a left-over of the regressions introduced with PR 18126.
Thanks to some moderinization of the code base and replacing static with dynamic casts undefined behaviour
has changed to well-defined behaviour but now unchecked null pointers.

This change does some extra null pointer checks and uses the now correct types for down casting.

Hint: Upstream still uses many static casts here that already cause undefined behaviour when creating a LCS.
This could be the reason for the possible crashes when deleting a LCS as described in 20261

# Conflicts:
#	src/Gui/ViewProviderCoordinateSystem.cpp
2025-06-11 08:26:17 +02:00
Ladislav Michl
a37509956e Gui: fix ViewProviderCoordinateSystem::claimChildren()
Until 8de6382 ("Gui: Fix stackoverflow when loading corrupted file")
a static_cast was used to obtain App::Origin object, however with
introducing App::LocalCoordinateSystem this was no longer correct,
although not causing any troubles as OriginFeatures moved into
LocalCoordinateSystem as well.

Recent use of getObject template triggered this problem, so use now
correct cast to App::LocalCoordinateSystem.

Fixes: 19702dc ("Core: Add App::LocalCoordinateSystem")
2025-06-10 10:20:06 +02:00
wmayer
efe02a8675 Gui: Fix stackoverflow when loading corrupted file
If an object has a link to itself it may cause a stackoverflow
in several cases:
* If the method claimChildren3D() returns a list containing the
  object of the view provider then Document::handleChildren3D()
  will add a SoGroup to itself as a child. This will result into
  a stackoverflow as soon as an action traverses the scene.
* If the method claimChildren() returns a list containing the
  object of the view provider then DocumentItem::createNewItem()
  causes an infinite loop with DocumentItem::populateItem()

Solution:
* Inside Document::handleChildren3D() avoid to add a SoGroup to itself
* In this specific case fix ViewProviderCoordinateSystem::claimChildren()
  to avoid a cyclic dependency

Hint: Since PR 18126 FreeCAD is vulnerable for this problem.

This fixes issue 19682
2025-05-30 18:04:33 +02:00
bofdahof
ba2c2ca5ad Console: rename PascalCase named methods to camelCase 2025-05-06 17:50:21 +02:00
wmayer
e56b85f6e1 Gui: Use bitmask instead of three booleans in setTemporaryVisibility to improve readability 2024-12-31 13:29:01 +01:00
wmayer
b7b771cecb Gui: Reduce cognitive complexity of ViewProviderCoordinateSystem::setTemporaryVisibility 2024-12-30 19:03:58 +01:00
wmayer
0c14c673a9 Gui: Reduce code duplication in ViewProviderCoordinateSystem 2024-12-30 18:42:50 +01:00
PaddleStroke
4892fcaaf1 Core datums: Rework to improve new sketch 2024-12-30 09:05:44 +01:00
wmayer
0d4e7ac27f Core: Move LCS migration warning to Std_Open command 2024-12-16 11:34:39 -05:00
PaddleStroke
24ab20553d LCS migration : replace warning by a QMessageBox. 2024-12-13 18:04:10 +01:00
PaddleStroke
b2f965c06e ViewProviderOrigin: Renamed to ViewProviderCoordinateSystem 2024-11-27 12:15:53 +01:00