Commit Graph

277 Commits

Author SHA1 Message Date
flachyjoe
511b38ce24 [App] Fix file not found error with canonical filename
boost::filesystem::canonical doesn't resolve non existent file where
boost::filesystem::weakly_canonical does.

Notice boost::filesystem::weakly_canonical only resolve absolute path.
2022-07-04 00:50:43 +02:00
flachyjoe
8fba6b034d [App] Fix #5592 : Respect symbolic links
Use the real path to the file when saving the document.
2022-07-04 00:50:43 +02:00
Uwe
881b168beb [App] remove unnecessary Boolean comparisons 2022-06-19 15:18:34 +02:00
wmayer
2c7fce704f App: implement DocumentP::clearDocument() to reduce code duplication 2022-05-08 21:32:34 +02:00
wmayer
531b354229 App: fixes #6840: Crash in ObjectIdentifier::resolveProperty 2022-05-06 20:34:08 +02:00
Chris Hennes
f7edc74eee App: PR6497 move return statement to new line 2022-03-29 12:33:37 -05:00
Adrian
a6f881023f fix creation of backup file even when numberOfFiles<=0 in applyTimeStamp
and move file deletion inside if (fi.exists()) block
2022-03-28 19:17:43 +02:00
Adrian
cf2556db1b move tmp file rename after file deletion in applyTimeStamp when numberOfFiles <=0 [fixes #6532] 2022-03-28 19:17:43 +02:00
wmayer
1a20b7f119 App: modernize C++11
* use nullptr
2022-03-23 17:29:23 +01:00
wmayer
c6398bbbe0 App: make sure to create parent directories of a document's transient directory 2022-03-19 13:58:10 +01:00
wmayer
f1f68db55b App: Optimize includes to reduce compile time 2022-03-07 15:53:58 +01:00
wmayer
91e4e468dd Base: move ILogger sub-classes to their own source files in order to reduce including stream classes in client code 2022-03-06 10:13:47 +01:00
wmayer
9798e6de2b App: move member DocumentPythonObject to DocumentP 2022-03-03 20:28:47 +01:00
wmayer
e70170dbf3 App: [skip ci] Add enum value to suppress error messages on document recompute 2022-02-28 17:54:25 +01:00
Uwe
09ce5ce137 [App] Document: remove unused includes 2022-02-23 01:56:26 +01:00
Uwe
16467d9067 Revert "App: fix property ordering problem when undo/redo (#3255)"
This reverts commit 24d30636e4fb990fdbd67538360846ff09456dfc.
2022-02-22 01:21:49 +01:00
Zheng Lei
170a12089c App: fix property ordering problem when undo/redo (#3255)
* Part: fix Placement/Shape onChanged() handling

* App: fix property ordering problem when undo/redo
See https://tracker.freecadweb.org/view.php?id=4265#c14271

* Gui: fix undo/redo signaling
Make sure to signal after all properties has been restored
2022-02-21 12:29:01 +01:00
marioalexis
950a859842 App: Prevent crash when trying to delete pointer to BaseClass 2022-01-19 08:14:41 +01:00
Zheng, Lei
611e79af53 App: insert UUID property to trace the source of copied object
A property _ObjectUUID will be added to an object before it is being to
copied, if the property does not exists. Anoter propert _SourceUUID
property will be added to any copied object, with value set to its
source objct's _ObjectUUID.
2021-12-21 21:41:02 -07:00
Zheng, Lei
156b6aa359 App: fix pending object remove on recomputing 2021-12-21 21:41:02 -07:00
wmayer
387661360c App: standard path handling
* distinguish between temp and cache location
* document's transident directory is created in the cache location
* add functions to access temp and cache location via Python
2021-11-15 16:26:25 +01:00
Zheng, Lei
fdae470c1b App: add hiddenref() expression built-in function
Any object reference inside this function is treated as hidden to
exclude it from dependency calculation. This function allows some form
of cyclic depdenency.

Merger note: renamed from "HREF" to "HIDDENREF" to avoid confusion with
the standard "hypertext reference" use of HREF.
2021-11-14 20:45:09 -06:00
wmayer
f36126770c App: harmonize API of App::Application
* make getHomePath() static and return a std::string
* make getExecutableName() static and return a std::string
2021-11-04 10:50:09 +01:00
Zheng, Lei
ad9ad30c00 App: fix external document loading
The problem happens when partial loading is enabled. If document A
contains a link to some object in document B, it will load B as partial
document with only that object and its necessary dependencies. But if
document A contains another link to some object in document C which also
has a link to some object in document B, the link in document C may not
be restored, because document B is partially loaded without the linked
object. This patch will check for this case and reload document B for
more objects.

See an example reported in
https://forum.freecadweb.org/viewtopic.php?p=495078#p495078
2021-10-30 11:03:52 +08:00
wmayer
77b09a97f8 App: correctly handle UTF-8 encoded path names under Windows 2021-09-29 13:47:29 +02:00
Ajinkya Dahale
92b3a5430a [App] Fix regression introduced by PR #4996
Files opened by running `freecad xxxx.FCStd` or similar relative paths could not
be saved because of new code introduced to create parent directories. See
https://github.com/FreeCAD/FreeCAD/pull/4996#issuecomment-922370077 and
https://forum.freecadweb.org/viewtopic.php?f=13&t=62319&p=534156#p534156.

This commit resolves the issue by ensuring the parent path is absolute while
saving. We would probably like to make sure the file name is itself stored with
absolute path, but there's a few problems
1. There may be other occurences where files are loaded with relative paths. So
having a check here is a good idea.
2. Files opened by `freecad xxxx.FCStd` somehow don't have the issue where
renaming parent directory throws an exception on save. Instead the file is saved
in the new location.
2021-09-29 13:35:02 +02:00
Yorik van Havre
ef365386ef Merge pull request #4800 from heewa/abort-save-when-unable-to-finish
App: Abort save when unable to finish
2021-09-20 10:47:57 +02:00
wmayer
44272480f4 App: handle empty, . or .. as parent directory 2021-09-19 18:06:47 +02:00
Ajinkya Dahale
c123bc2bf8 [Core] (Partially?) Fix data loss on dir rename (#4996)
* Fix lost filename in err msg

In some circumstances, FileExceptions are constructed empty, then have a
filename assigned to them, but the error message in these scenarios is
left as the default "unknown" one, which is sometimes shown to users.
This change fixes that case to be consistent with instances that are
constructed with the filename.

The exception can happen when trying to save the file in a location that does
not exist, or when the user does not have permission to write there. If it
comes when saving after closing the document, all previous changes can be lost.

Partially fixes issue #4098.

Co-authored-by: Heewa Barfchin <heewa.b@gmail.com>
2021-09-16 12:06:29 -05:00
Heewa Barfchin
5beedc6efd App: Abort save when unable to finish
In these two cases, the project's file will not contain the latest
changes, so returning as if the save is complete is incorrect and can
lead to data loss (such as on app quit).
2021-05-18 11:20:00 -04:00
wmayer
f0740edd20 App: [skip ci] AddressSanitizer: heap-use-after-free
In Document::removeObject() do not access object after it has been possibly deleted
2021-02-23 14:30:00 +01:00
Chris Hennes
0a4ff764e9 LGTM: Move seq->next out of loop control
LGTM points out that the construct use in the loop here "does
nothing" -- that is, it is a conditional whose result is never used.
It is apparently being used simply to ensure that the next() function is
called on each loop iteration, but because sequence may be null, it is
shoehorned into a trinary :? operator. To clarify the intent and ensure
that later readers (including LGTM) do not misunderstand it,
this code is broken out into a more standard conditional construct at
the end of each loop iteration.
2021-02-11 12:31:25 +01:00
Abdullah Tahiri
05ccc95cde App/Gui: New restoreError Document status and Gui pop-up
========================================================

If the restore of Document.xml results in invalid Document.xml (because unhandled exceptions occurred), the
document status Document::restoreError is set. The GUI or Mod/Web if a link was clicked, show a pop-up indicating
this situation.

This commit also shows an appropriate pop-up for the partialRestore when opening from the menu, that before only
appeared when opening by clicking a link.
2021-01-24 16:43:20 +01:00
wmayer
eac4062b3f Boost: [skip ci] Fix build warnings from deprecated Boost headers (v1.75) 2020-12-29 15:34:25 +01:00
luz paz
84553bf191 App: Fix header uniformity, trailing whitespace, and doxygen headers 2020-11-19 13:38:37 +01:00
wmayer
cd0dfe1e87 App: [skip ci] fix printing warning for recursive calls of Document::_commitTransaction 2020-10-23 20:50:23 +02:00
wmayer
fbcf8dfa5d App: [skip ci] fix possible segmentation fault when performing a transaction after an undo 2020-10-23 19:47:33 +02:00
Zheng, Lei
b2624c08a1 App: fix recursive App::getLinksTo() 2020-09-27 12:59:38 +02:00
Zheng, Lei
f67d960146 App: record transaction on non DocumentObject
Related #0004265
2020-09-04 16:01:21 +02:00
wmayer
a7738cec07 App: [skip ci] for a recompute do not report every exception as error
There are a lof of scenarios where it's not possible to perform an operation without throwing an exception. Reporting an exception as error is not only annoying but often confusing because the user assumes he did something wrong.
So, for the moment many of these exceptions are reported as log messages but serious things like memory exception, std. C++ exceptions or unknown C++ exceptions are still reported as errors
2020-07-31 13:59:40 +02:00
wmayer
89f997a289 Coverity: Use after free (_removeObject may delete the DocumentObject) 2020-07-20 17:34:24 +02:00
wmayer
02f45721d6 PVS: V529 Odd semicolon ';' after 'for' operator. 2020-07-18 10:59:27 +02:00
Zheng, Lei
36d046d489 App/Gui: introduce temporary document
Add new argument to Application::newDocument() to create a temporary
    document. Also exposed to Python API App.newDocument() with a named
    argument 'temp'.

    The temporary document is marked with status bit 'TempDoc'. The user
    will not be prompt for saving when closing. The undo/redo is disabled.
    The AutoSaver skips it. And the tree view will not show it.
    PropertyXLink allows linking to/from object within a temporary document
    without saving.
2020-07-14 19:36:05 +02:00
luz.paz
ef37cc3930 Fix typos [skip-ci]
Found via codespell v1.18.0.dev0  
```
codespell -q 3 -L aci,ake,aline,alle,alledges,alocation,als,ang,anid,ba,beginn,behaviour,bloaded,byteorder,calculater,cancelled,cancelling,cas,cascade,centimetre,childs,colour,colours,commen,connexion,currenty,dof,doubleclick,dum,eiter,elemente,ende,feld,finde,findf,freez,hist,iff,indicies,initialisation,initialise,initialised,initialises,initialisiert,ist,kilometre,lod,mantatory,methode,metres,millimetre,modell,nd,noe,normale,normaly,nto,numer,oder,orgin,orginx,orginy,ot,pard,pres,programm,que,recurrance,rougly,seperator,serie,sinc,strack,substraction,te,thist,thru,tread,uint,unter,vertexes,wallthickness,whitespaces -S ./.git,*.po,*.ts,./ChangeLog.txt,./src/3rdParty,./src/Mod/Assembly/App/opendcm,./src/CXX,./src/zipios++,./src/Base/swig*,./src/Mod/Robot/App/kdl_cp,./src/Mod/Import/App/SCL,./src/WindowsInstaller,./src/Doc/FreeCAD.uml
```
2020-06-29 20:52:23 +02:00
wmayer
d21cd009b1 App: extend Document::findObject to allow to search by label 2020-06-27 15:58:23 +02:00
wmayer
d6169d6478 boost: fix for boost < 1.60 2020-06-15 19:38:39 +02:00
wmayer
1f7818f977 Gui: [skip ci] show program version a file was created with in project information dialog 2020-06-14 17:52:02 +02:00
Abdullah Tahiri
94fda2ec89 Document/DocumentObject: onUndoRedoFinished()
=============================================

New mechanism for on-demand signaling of undo/redo transaction finalisation.

The mechanism consists of:
1) A status bit that is set, when an object should receive this signaling (e.g. because changes during transaction have been inhibited)
2) The new function to be called by the Document undo/redo actions when the transaction is over (for those objects having the status bit set).

Note 1: The undo/redo signals are now outside the undoing FlagToggler, this means that:
1) a call to isPerformingTransaction will return false.
2) a recompute the slot of such a signal will not be inhibited.

Note 2: The undo/redo signals are called once the documentobjects that requested to be notified after the trasaction is over have been notified.
The consequence is that the viewprovider can rely on the documentobject having a correct status.

I think that the behaviour of Note and Note 2 is the wanted behaviour of this signals, I cannot rule out that other parts of FC rely on the old
implementation.
2020-06-14 14:44:28 +02:00
wmayer
730154a684 boost 1.73.0: The practice of declaring the Bind placeholders (_1, _2, ...) in the global namespace is deprecated 2020-06-12 17:51:33 +02:00
wmayer
f317f05837 App: [skip ci] handle XMLAttributeError in Document::readObjects 2020-06-07 14:25:32 +02:00