New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TD: replace usage of raw pointers of Vertex and Face with shared poin… #5231
Conversation
…ters. This fixes issue 4741: Broken File After Using Landmark Dimension in TechDraw
Is there something in particular you want reviewed here, or just normal testing? |
Well, TD is not my domain and I didn't want to simply push a fix that modifies many files that others might not be happy with. That's why I wanted to hear a second opinion. The technical aspect: Because of this I replaced the affected raw pointers with shared pointers to avoid double deletion and fix possible memory leaks. |
If nobody has any reservations I will merge it shortly. |
I'm always a fan of smart pointers in ownership situations, so I think this is an excellent thing. |
Yes. And TD in general needs a thorough review. I once worked to fix the mess with pages and its displayed childs but I felt I could only cure symptoms, not the main causes.
Long story short, when you see strange code, any improvement like this PR is highly appreciated. |
A general rework at this point is difficult and actually not needed because the basic design still looks OK to me. A good idea always is code-refactoring where big functions are split into smaller ones. This automatically reduces duplicated code and may fix inconsistencies.
For this we should have a good test file that eventually could be added to the examples directory. In a second step a profiler must be used to identify the code parts that are called too often.
TD depends on many other extension modules like Measure, Part, Spreadsheet, Drawing and Import. And of course it depends on the changes of the other modules.
I have seen many cases where inside the constructor of a class certain things are checked and if not fulfilled the further initialization is aborted and a message is printed. To avoid possible crashes the affected methods are full of checks not to call the null pointer member variables. In some cases the better alternative would have been to throw an exception in the constructor in order to clean-up the whole instance. |
OK, I press the red button now :) |
Do you think this can be backported? |
@kbwbe provided last year some good test cases. I searched the forum but cannot find the thread where we once discussed with @WandererFan .
What I mean is that when TD has to be recompiled because something changed in the code of FC, almost all TD files are recomputed. This is not the case for the other WBs. |
This PR causes errors in the files CommandExtensionDims.cpp and CommandExtensionPack.cpp used in PR5144. |
This PR is not yet merged and since this PR here is in and changed some D basics, you must rebase your PR to current master and then adapt your code in necessary. As another reviewers already wrote in your PR, the best is to make PRs that each change a small portion. This assures it will get reviewed quickly and then merged. |
…ters.
This fixes issue 4741: Broken File After Using Landmark Dimension in TechDraw
Thank you for creating a pull request to contribute to FreeCAD! To ease integration, we ask you to conform to the following items. Pull requests which don't satisfy all the items below might be rejected. If you are in doubt with any of the items below, don't hesitate to ask for help in the FreeCAD forum!
App
,Base
,Gui
or one of theMod
subfolders. If you need to make changes in several locations, make several pull requests and wait for the first one to be merged before submitting the next onesgit pull --rebase upstream master
./bin/FreeCAD --run-test 0
Fixes typo in Draft Move command text
Draft: Fixed typos
issue #<id>
orfixes #<id>
where<id>
is the FreeCAD bug tracker issue number in case a particular commit solves or is related to an existing issue on the tracker. Ex:Draft: fix typos - fixes #0004805
And please remember to update the Wiki with the features added or changed once this PR is merged.
Note: If you don't have wiki access, then please mention your contribution on the 0.20 Changelog Forum Thread.