0.21master, error while working in PD and new task do not start

Recently i get a weird behavior while working with PartDesign. On every new function, the task dialog does not start, but when doubleclick on the feature in the tree, the task dialog works fine. The issue seems, that while starting a new function, that an error occurs.

Example:
2023-06-17 19-21.webm

Here it refuse to start the sketcher properly and refuses to start the pocket task dialog. While starting the sketch i get:

<Gui> Document.cpp(384): Invalid sub object 'Yoke#Part.Body.Sketch001.Body.'

and while starting the pocket i get:

<Gui> Document.cpp(384): Invalid sub object 'Yoke#Part.Body.Pocket.Body.'

error messages.


File:
Yoke.FCStd
Version (fresh build clean from scratch):

OS: Debian GNU/Linux 11 (bullseye) (X-Cinnamon/lightdm-xsession)
Word size of FreeCAD: 64-bit
Version: 0.21.0.33411 (Git)
Build type: Release
Branch: master
Hash: 127404d793d5c2081383b46a7b677426d9a0c5aa
Python 3.9.2, Qt 5.15.2, Coin 4.0.0, Vtk 9.0.1, OCC 7.7.1
Locale: English/United States (en_US)
Installed mods: 
  * QuickMeasure 2022.10.28
  * Assembly4 0.12.6
  * CurvedShapes 1.0.4
  * Curves 0.6.8

Greetings
user1234

The issue is introduced here:

a3c4f4bb01f5201daf666852444a8f9c5adbda8d

adrianinsaval or wmayer : can you please have a look? Could it be, that in new line 98 parent and subname is swapped? no it is not.


Greetings
user1234

edit: stroke and red

I’ve watched your screen capture but I can’t replicate it using:

OS: Linux Mint 20.3 (X-Cinnamon/cinnamon)
Word size of FreeCAD: 64-bit
Version: 0.21.0.33411 (Git)
Build type: Release
Branch: master
Hash: 127404d793d5c2081383b46a7b677426d9a0c5aa
Python 3.8.10, Qt 5.12.8, Coin 4.0.0, Vtk 7.1.1, OCC 7.7.1
Locale: English/United Kingdom (en_GB)
Installed mods: 
  * Silk 0.1.3
  * A2plus
  * Defeaturing 1.2.0
  * CurvedShapes 1.0.4
  * MakerWorkbench 1.0.1
  * freecad.gears 1.0.0
  * Curves 0.6.8
  * toSketch 1.0.1
  * Plot 2022.4.17
  * AirPlaneDesign 0.4.0
  * fasteners 0.4.56
  * sheetmetal 0.2.63

confirmed, interestingly, it works on first try but if you try activating the body and then creating a sketch it doesn’t here’s steps to reproduce from scratch:
-new document
-create Part
-create Body (body is automatically placed inside Part), however it is not highlighted as activated
(if you try now to create a sketch in this moment it works without problems)
-double click on Body to activate it
-attempt creating a sketch on body (or launch any PD task really), the task is not launched and the error shown in report view

14:57:31  <Gui> Document.cpp(385): Invalid sub object 'Unnamed#Part.Body.Box.Body.'

further discussion here please: 9792

-create Body (body is automatically placed inside Part), however it is not highlighted as activated

When creating the Body then it IS highlighted and it IS activated. To reproduce the problem described by the OP I have to manually deactivate the Body before creating the sketch.

What happens is that

auto activeBody = activeView->getActiveObject<PartDesign::Body*>(PDBODYKEY,&parent,&subname);

unexpectedly sets subname to “Body”. Afterwards when calling getParent() then the string “Body.Sketch.” is prepended and “.” appended which results into the incorrect subname “Body.Sketch001.Body.”.

Fixing the issues is easy: before calling getParent() the string subname must be cleared.