Bug: Draft user interface settings tab not loaded by Arch

A forum dedicated to the Draft, Arch and BIM workbenches development.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
matthijskooijman
Posts: 72
Joined: Thu Mar 25, 2021 10:59 am

Bug: Draft user interface settings tab not loaded by Arch

Post by matthijskooijman »

The draft workbench has 5 tabs in its preferences:

Image

However, when you open the Arch workbench (before the Draft workbench), you get only 4:

Image

This seems to be cause both the Arch and Draft workbenches have some duplicate code for loading the preferences pages, and the Arch copy is incomplete (probably forgotten in a recent update):

https://github.com/FreeCAD/FreeCAD/blob ... #L145-L150
https://github.com/FreeCAD/FreeCAD/blob ... #L117-L123

I'm not sure what the best fix would be. The easiest would be to just update the Arch code. However, this does not fix the underlying issue (code duplication) that caused this issue to appear in the first place. A nicer fix would be to put this code into a separate method of the DraftWorkBench class and call that from the ArchWorkBench.Initialize method.

Somewhat related, I wonder why draftToolBar.loadedArchPreferences is used. Looking at other workbenches (i.e. OpenSCAD), they just call addPreferencePage in their Initialize method unconditionally, so I assume that Initialize is only called once for each workbench. Having draftToolBar.loadedPreferences makes sense, since those can be loaded from both the Arch and Draft toolbar, but for the arch preferences, this is not the case (so maybe this check was added just by mirroring the draft check, without realizing it is not needed)? I can even imagine that with the above suggestion of a DraftWorkBench.addPreferences() methods or so, that draftToolBar.loadedPreferences could be replaced by a static member of module level variable in DraftWorkBench, which would make things more self-contained as well.

Any suggestion on what the preferred solution would be? Maybe I could find some time to prepare a PR, then.
Post Reply