Commit Graph

2190 Commits

Author SHA1 Message Date
Chris Hennes
4ef5452cab Merge pull request #20049 from hyarion/fix/ppa
Refactor static type checks
2025-03-10 16:53:00 +00:00
Chris Hennes
d099225d88 Merge pull request #20064 from bofdahof/application-remove-some-using-namespace
[App] Application remove some using namespace
2025-03-10 16:42:28 +00:00
Benjamin Nauck
cc6dcbd7e6 Refactor static type checks 2025-03-09 17:50:20 +01:00
bofdahof
b0d34801db cleanup commented lines 2025-03-08 13:37:46 +10:00
bofdahof
7b3b7068ca remove using namespace Base::FileInfo 2025-03-08 13:37:46 +10:00
bofdahof
bfe6d21163 remove using namespace boost::program_options 2025-03-08 13:20:32 +10:00
bofdahof
1dc20ee0d6 remove using namespace std 2025-03-08 13:18:06 +10:00
bofdahof
7a69a7d8c3 remove using namespace boost 2025-03-08 13:14:35 +10:00
bofdahof
5f691bee69 remove using namespace Base 2025-03-08 13:13:38 +10:00
Chris Hennes
feb58cca04 Merge pull request #20052 from mosfet80/CleanPython
removed old python code <3.10
2025-03-08 01:10:58 +00:00
Chris Hennes
144b44f2db Merge pull request #20058 from tritao/fix-app-document-main-doc-load
App: Fix regression for document creation requests coming from the main document.
2025-03-07 23:28:27 +00:00
mos
9f220319d0 Removed old Python code <3.10 2025-03-07 16:34:08 -06:00
Joao Matos
08564607c2 App: Fix regression when creating new document coming from the main document. 2025-03-07 20:54:16 +00:00
Joao Matos
6dd5246fa1 Rename DocumentCreateFlags to DocumentInitFlags. 2025-03-07 20:54:16 +00:00
Joao Matos
ed111d1f8e App: Fix memory leak regression in ApplicationPy::newDocument. 2025-03-07 20:42:51 +00:00
Joao Matos
81a5b78b36 Convert DocumentCreateFlags instances to use designated initializer list. 2025-03-07 20:42:51 +00:00
Chris Hennes
caccda384b App: Cleanup parameter names in Application.*
* Unify names in header and cpp files
* Make names consistent across methods with similar uses
* Fix spacing

Co-authored-by: Benjamin Nauck <benjamin@nauck.se>
2025-03-07 08:47:49 -06:00
Kevin Martin
e864b17a5a Only do Label Change notification if the label truly changes
The code for setting the value of a Label property would do a quick return if the new label was equal to the current one, but otherwise the proposed new label might be modified to make it unique. If the modified new value were equal to the current value, a Change notification would still be generated. This no longer occurs.
2025-03-05 22:23:43 -05:00
Kevin Martin
3b87c991cb Deregister DocumentObject's Label before deleting the object
Under certain circumstances the existing code would try to obtain the Label of a DocumentObject after that object had been deleted, causing an access to freed memory and failing to deregister the Label. The latter would lead to phanton Label collisions and unexpected generation of unique labels.
2025-03-05 22:23:42 -05:00
Chris Hennes
070e2cc8fa App: Switch to isNullOrEmpty() 2025-03-03 19:24:15 -06:00
Chris Hennes
94adb6b28b App: Minor formatting from review
Co-authored-by: Benjamin Nauck <benjamin@nauck.se>
2025-03-03 19:21:05 -06:00
bofdahof
9f880497ed Calling static via instance 2025-03-03 19:21:04 -06:00
bofdahof
80b3a7e3de Narrowing conversion 2025-03-03 19:21:04 -06:00
bofdahof
9d11fb9079 Don't use endl 2025-03-03 19:21:04 -06:00
bofdahof
65895ae0ed Reserve vector size 2025-03-03 19:21:04 -06:00
bofdahof
e5497af44b Redundant c_str() 2025-03-03 19:21:04 -06:00
bofdahof
f6f759a992 Else after return 2025-03-03 19:21:04 -06:00
bofdahof
e1eb7e6643 Declaration hides previous 2025-03-03 19:21:04 -06:00
bofdahof
0a4d9a2b37 C++ style cast instead of C 2025-03-03 19:21:04 -06:00
bofdahof
bffdf7feb2 Join declaration and assignment 2025-03-03 19:21:04 -06:00
bofdahof
1e4cecdc07 Use auto 2025-03-03 19:21:04 -06:00
bofdahof
a1c9ed4385 Simplify expression 2025-03-03 19:21:04 -06:00
bofdahof
668aaf7511 DRY 2025-03-03 19:20:59 -06:00
Chris Hennes
1a2070c36f Merge pull request #19636 from kadet1090/color-in-base
Base: Move App::Color to Base
2025-03-02 16:36:40 -06:00
Chris Hennes
50adb86a1f Merge pull request #19761 from chennes/coverityFixesFeb2025
Base: Coverity fixes from February 2025 run (round 1)
2025-03-02 16:15:17 -06:00
Joao Matos
6797cfdfbe App: Remove old DAG implementation. 2025-02-28 14:32:32 +00:00
Benjamin Bræstrup Sayoc
ee1c73cd04 Build: suppress warnings from 3rd party libraries
Warnings from 3rd parties are not relevant and are only polluting the warning output. Marking these libraries as SYSTEM suppresses warning.

https://gcc.gnu.org/onlinedocs/cpp/Invocation.html#index-I
https://gcc.gnu.org/onlinedocs/cpp/System-Headers.html
2025-02-25 14:39:05 +00:00
Chris Hennes
dce7627c33 Merge pull request #19516 from tritao/tools-python-bindings-gen
Tools: Introduce a new Python-based C++ bindings generator
2025-02-24 16:39:24 +00:00
Joao Matos
15076cb504 Core: Move PyCXX library to src/3rdParty. 2025-02-24 16:36:06 +00:00
Kevin Martin
edb8e4c937 Address performance of existing unique-name generation (Part 2) (#18676)
As described in Issue 16849, the existing Tools::getUniqueName method
requires calling code to form a vector of existing names to be avoided.

This leads to poor performance both in the O(n) cost of building such a
vector and also getUniqueName's O(n) algorithm for actually generating
the unique name (where 'n' is the number of pre-existing names).

This has  particularly noticeable cost in documents with large numbers
of DocumentObjects because generating both Names and Labels for each new
object incurs this cost. During an operation such as importing this
results in an O(n^2) time spent generating names.

The other major cost is in the saving of the temporary backup file,
which uses name generation for the "files" embedded in the Zip file.
Documents can easily need several such "files" for each object in the
document.

This update includes the following changes to use the newly-added
UniqueNameManager as a replacement for the old Tools::getUniqueName
method and deletes the latter to remove any temptation to use it as
its usage model breeds inefficiency:

Eliminate Tools::getUniqueName, its local functions, and its unit tests.

Make DocumentObject naming use the new UniqueNameManager class.

Make DocumentObject Label naming use the new UniqueNameManager class.
This needs to monitor DocumentObject Labels for changes since this
property is not read-only. The special handling for the Label
property, which includes optionally forcing uniqueness and updating
links in referencing objects, has been mostly moved from
PropertyString to DocumentObject.

Add Document::containsObject(DocumentObject*) for a definitive
test of an object being in a Document. This is needed because
DocumentObjects can be in a sort of limbo (e.g. when they are in the
Undo/Redo lists) where they have a parent linkage to the Document but
should not participate in Label collision checks.

Rename Document.getStandardObjectName to getStandardObjectLabel
to better represent what it does.

Use new UniqueNameManager for Writer internal filenames within the zip
file.

Eliminate unneeded Reader::FileNames collection. The file names
already exist in the FileList collection elements. The only existing
use for the FileNames collection was to determine if there were any
files at all, and with FileList and FileNames being parallel
vectors, they both had the same length so FileList could be used
for this test..

Use UniqueNameManager for document names and labels. This uses ad hoc
UniqueNameManager objects created on the spot on the assumption that
document creation is relatively rare and there are few documents, so
although the cost is O(n), n itself is small.

Use an ad hoc UniqueNameManager to name new DymanicProperty entries.
This is only done if a property of the proposed name already exists,
since such a check is more-or-less O(log(n)), almost never finds a
collision, and avoids the O(n) building of the UniqueNameManager.
If there is a collision an ad-hoc UniqueNameManager is built
and discarded after use.
The property management classes have a bit of a mess of methods
including several to populate various collection types with all
existing properties. Rather than introducing yet another such
collection-specific method to fill a UniqueNameManager, a
visitProperties method was added which calls a passed function for
each property. The existing code (e.g. getPropertyMap) would be
simpler if they all used this but the cost of calling a lambda
for each property must be considered. It would clarify the semantics
of these methods, which have a bit of variance in which properties
populate the passed collection, e.g. when there are duplicate names..
Ideally the PropertyContainer class would keep a central directory of
all properties ("static", Dynamic, and exposed by ExtensionContainer and
other derivations) and a permanent UniqueNameManager. However the
Property management is a bit of a mess making such a change a project
unto itself.
2025-02-24 10:23:53 -06:00
Kacper Donat
36195d1981 Base: Add fromPercent and toPercent helpers 2025-02-23 22:51:13 +01:00
Kacper Donat
55dfa203a8 Update src/App/Application.cpp
Co-authored-by: Benjamin Nauck <benjamin@nauck.se>
2025-02-21 15:04:43 +01:00
Kacper Donat
cc2efa90f8 Base: Add isNullOrEmpty string helper
This adds isNullOrEmpty string helper that cheks if string is... well
null or empty. It is done to improve readability of the code and better
express intent.
2025-02-21 15:04:43 +01:00
tritao
537b51d038 CMake: Rename generate_from_py macro to generate_embed_from_py. 2025-02-21 13:18:36 +00:00
Chris Hennes
45f913eb9e App: Small fixes caught by Coverity scan 2025-02-20 22:00:40 -06:00
Benjamin Bræstrup Sayoc
6f619b5f1c Base: remove unneeded includes 2025-02-18 11:07:57 -06:00
Kacper Donat
13fbab9e42 Base: Move App::Color to Base
Every basic data type is stored in Base module, color is standing out as
one that does not. Moving it to Base opens possibilities to integrate it
better with the rest of FreeCAD.
2025-02-17 21:10:26 +01:00
Benjamin Nauck
0ba52f0e22 Make modulo require units to be same or dimensionless
Fixes #19517
2025-02-17 11:31:17 -06:00
Joao Matos
aace8f7bee CMake: Modernize build files using outdated Python variables. 2025-02-16 10:21:26 -06:00
Andrea
146d8a356b change MIN_boost_version
ubuntu version 20.04 is no longer supported.
The minimum boost version used for freecad is now 1.74 (ubuntu 22.04) https://launchpad.net/ubuntu/jammy/+package/libboost-system-dev
2025-02-15 13:33:32 -06:00