Skip to content

Commit

Permalink
Merge branch 'master' into allow-neg-boundary-limits
Browse files Browse the repository at this point in the history
  • Loading branch information
sliptonic committed Feb 17, 2020
2 parents aea1330 + 01e8e7f commit ca7b587
Show file tree
Hide file tree
Showing 162 changed files with 6,319 additions and 3,442 deletions.
243 changes: 117 additions & 126 deletions .travis.yml

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions CMakeLists.txt
Expand Up @@ -28,6 +28,8 @@ set(PACKAGE_VERSION_NAME "Vulcan")
set(PACKAGE_VERSION_MAJOR "0")
set(PACKAGE_VERSION_MINOR "19")
set(PACKAGE_VERSION_PATCH "16100")
set(PACKAGE_VERSION_SUFFIX "dev") # either "dev" for development snapshot or "" (empty string)
set(FREECAD_VERSION_PATCH "0") # number of patch release (e.g. "4" for the 0.18.4 release)

set(FREECAD_VERSION "${PACKAGE_VERSION_MAJOR}.${PACKAGE_VERSION_MINOR}")
set(PACKAGE_VERSION "${PACKAGE_VERSION_MAJOR}.${PACKAGE_VERSION_MINOR}.${PACKAGE_VERSION_PATCH}")
Expand Down
Expand Up @@ -13,7 +13,11 @@ macro(SetGlobalCompilerAndLinkerSettings)
message(STATUS "Platform is 32-bit")
endif(CMAKE_SIZEOF_VOID_P EQUAL 8)


# check for mips64 platform
if("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "mips64")
message(STATUS "Architecture: mips64")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mxgot")
endif()

if(MSVC)
# set default compiler settings
Expand Down
6 changes: 6 additions & 0 deletions cMake/FreeCAD_Helpers/SetupPython.cmake
Expand Up @@ -119,6 +119,12 @@ macro(SetupPython)
endif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin" AND NOT BUILD_WITH_CONDA)

find_package(PythonInterp REQUIRED)

# Issue in cmake prevents finding pythonlibs 3.x when python 2.7 is present
# setting NOTFOUND here resolves the issue
set(PYTHON_INCLUDE_DIR "NOTFOUND")
set(PYTHON_LIBRARY "NOTFOUND")

set(Python_ADDITIONAL_VERSIONS ${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR})
if (NOT DEFINED PYTHON_VERSION_STRING)
find_package(PythonLibs REQUIRED)
Expand Down
50 changes: 41 additions & 9 deletions src/App/Application.cpp
Expand Up @@ -621,7 +621,7 @@ std::vector<Document*> Application::openDocuments(const std::vector<std::string>
for (auto &name : filenames)
_pendingDocs.push_back(name.c_str());

std::deque<std::pair<Document *, DocTiming> > newDocs;
std::map<Document *, DocTiming> newDocs;

FC_TIME_INIT(t);

Expand Down Expand Up @@ -655,7 +655,7 @@ std::vector<Document*> Application::openDocuments(const std::vector<std::string>
auto doc = openDocumentPrivate(path, name, label, isMainDoc, createView, objNames);
FC_DURATION_PLUS(timing.d1,t1);
if (doc)
newDocs.emplace_front(doc,timing);
newDocs.emplace(doc,timing);

if (isMainDoc)
res[count] = doc;
Expand Down Expand Up @@ -703,19 +703,50 @@ std::vector<Document*> Application::openDocuments(const std::vector<std::string>
_pendingDocMap.clear();

Base::SequencerLauncher seq("Postprocessing...", newDocs.size());

std::vector<Document*> docs;
docs.reserve(newDocs.size());
for (auto &v : newDocs) {
// Notify ProeprtyXLink to attach newly opened documents and restore
// relavant external links
PropertyXLink::restoreDocument(*v.first);
docs.push_back(v.first);
}

// After external links has been restored, we can now sort the document
// according to their dependency order.
docs = Document::getDependentDocuments(docs, true);
for (auto it=docs.begin(); it!=docs.end();) {
Document *doc = *it;
// It is possible that the newly opened document depends on an existing
// document, which will be included with the above call to
// Document::getDependentDocuments(). Make sure to exclude that.
auto dit = newDocs.find(doc);
if (dit == newDocs.end()) {
it = docs.erase(it);
continue;
}
++it;
FC_TIME_INIT(t1);
v.first->afterRestore(true);
FC_DURATION_PLUS(v.second.d2,t1);
// Finalize document restoring with the correct order
doc->afterRestore(true);
FC_DURATION_PLUS(dit->second.d2,t1);
seq.next();
}

if (!newDocs.empty())
setActiveDocument(newDocs.back().first);
// Set the active document using the first successfully restored main
// document (i.e. documents explicitly asked for by caller).
for (auto doc : res) {
if (doc) {
setActiveDocument(doc);
break;
}
}

for (auto &v : newDocs) {
FC_DURATION_LOG(v.second.d1, v.first->getName() << " restore");
FC_DURATION_LOG(v.second.d2, v.first->getName() << " postprocess");
for (auto doc : docs) {
auto &timing = newDocs[doc];
FC_DURATION_LOG(timing.d1, doc->getName() << " restore");
FC_DURATION_LOG(timing.d2, doc->getName() << " postprocess");
}
FC_TIME_LOG(t,"total");

Expand Down Expand Up @@ -1702,6 +1733,7 @@ void Application::initTypes(void)
App ::PropertyXLink ::init();
App ::PropertyXLinkSub ::init();
App ::PropertyXLinkSubList ::init();
App ::PropertyXLinkList ::init();
App ::PropertyXLinkContainer ::init();
App ::PropertyMatrix ::init();
App ::PropertyVector ::init();
Expand Down
13 changes: 13 additions & 0 deletions src/App/Application.h
Expand Up @@ -48,6 +48,7 @@ class DocumentObject;
class ApplicationObserver;
class Property;
class AutoTransaction;
class ExtensionContainer;

enum GetLinkOption {
/// Get all links (both directly and in directly) linked to the given object
Expand Down Expand Up @@ -261,6 +262,18 @@ class AppExport Application
/// signal on about changing the editor mode of a property
boost::signals2::signal<void (const App::Document&, const App::Property&)> signalChangePropertyEditor;
//@}

/** @name Signals of extension changes
* These signals are emitted on dynamic extension addition. Dynamic extensions are the ones added by python (c++ ones are part
* of the class definition, hence not dynamic)
* The extension in question is provided as parameter.
*/
//@{
/// signal before adding the extension
boost::signals2::signal<void (const App::ExtensionContainer&, std::string extension)> signalBeforeAddingDynamicExtension;
/// signal after the extension was added
boost::signals2::signal<void (const App::ExtensionContainer&, std::string extension)> signalAddedDynamicExtension;
//@}


/** @name methods for parameter handling */
Expand Down
74 changes: 72 additions & 2 deletions src/App/AutoTransaction.cpp
Expand Up @@ -21,7 +21,9 @@
****************************************************************************/

#include "PreCompiled.h"

#include <Base/Console.h>
#include <Base/Interpreter.h>
#include "Application.h"
#include "Transactions.h"
#include "Document.h"
Expand All @@ -31,6 +33,9 @@ FC_LOG_LEVEL_INIT("App",true,true)

using namespace App;

static int _TransactionLock;
static int _TransactionClosed;

AutoTransaction::AutoTransaction(const char *name, bool tmpName) {
auto &app = GetApplication();
if(name && app._activeTransactionGuard>=0) {
Expand Down Expand Up @@ -125,7 +130,11 @@ int Application::setActiveTransaction(const char *name, bool persist) {
AutoTransaction::setEnable(false);
return 0;
}
}else{
} else if (_TransactionLock) {
if (FC_LOG_INSTANCE.isEnabled(FC_LOGLEVEL_LOG))
FC_WARN("Transaction locked, ignore new transaction '" << name << "'");
return 0;
} else {
FC_LOG("set active transaction '" << name << "'");
_activeTransactionID = 0;
for(auto &v : DocMap)
Expand Down Expand Up @@ -156,10 +165,17 @@ void Application::closeActiveTransaction(bool abort, int id) {
return;
}

if(_TransactionLock) {
if(_TransactionClosed >= 0)
_TransactionLock = abort?-1:1;
FC_LOG("pending " << (abort?"abort":"close") << " transaction");
return;
}

FC_LOG("close transaction '" << _activeTransactionName << "' " << abort);
_activeTransactionID = 0;

TransactionSignaller siganller(abort,false);
TransactionSignaller signaller(abort,false);
for(auto &v : DocMap) {
if(v.second->getTransactionID(true) != id)
continue;
Expand All @@ -170,3 +186,57 @@ void Application::closeActiveTransaction(bool abort, int id) {
}
}

////////////////////////////////////////////////////////////////////////

TransactionLocker::TransactionLocker(bool lock)
:active(lock)
{
if(lock)
++_TransactionLock;
}

TransactionLocker::~TransactionLocker()
{
if(active) {
try {
activate(false);
return;
} catch (Base::Exception &e) {
e.ReportException();
} catch (Py::Exception &) {
Base::PyException e;
e.ReportException();
} catch (std::exception &e) {
FC_ERR(e.what());
} catch (...) {
}
FC_ERR("Exception when unlocking transaction");
}
}

void TransactionLocker::activate(bool enable)
{
if(active == enable)
return;

active = enable;
if(active) {
++_TransactionLock;
return;
}

if(--_TransactionLock != 0)
return;

if(_TransactionClosed) {
bool abort = (_TransactionClosed<0);
_TransactionClosed = 0;
GetApplication().closeActiveTransaction(abort);
}
}

bool TransactionLocker::isLocked() {
return _TransactionLock > 0;
}


47 changes: 47 additions & 0 deletions src/App/AutoTransaction.h
Expand Up @@ -25,6 +25,8 @@

namespace App {

class Application;

/// Helper class to manager transaction (i.e. undo/redo)
class AppExport AutoTransaction {
private:
Expand Down Expand Up @@ -79,6 +81,51 @@ class AppExport AutoTransaction {
int tid = 0;
};


/** Helper class to lock a transaction from being closed or aborted.
*
* The helper class is used to protect some critical transaction from being
* closed prematurely, e.g. when deleting some object.
*/
class AppExport TransactionLocker {
public:

/** Constructor
* @param lock: whether to activate the lock
*/
TransactionLocker(bool lock=true);

/** Destructor
* Unlock the transaction is this locker is active
*/
~TransactionLocker();

/** Activate or deactivate this locker
* @param enable: whether to activate the locker
*
* An internal counter is used to support recursive locker. When activated,
* the current active transaction cannot be closed or aborted. But the
* closing call (Application::closeActiveTransaction()) will be remembered,
* and performed when the internal lock counter reaches zero.
*/
void activate(bool enable);

/// Check if the locker is active
bool isActive() const {return active;}

/// Check if transaction is being locked
static bool isLocked();

friend class Application;

private:
/// Private new operator to prevent heap allocation
void* operator new(size_t size);

private:
bool active;
};

} // namespace App

#endif // APP_AUTOTRANSACTION_H
8 changes: 7 additions & 1 deletion src/App/Document.cpp
Expand Up @@ -91,6 +91,7 @@ recompute path. Also, it enables more complicated dependencies beyond trees.
#include <QCoreApplication>
#include <QCryptographicHash>

#include "AutoTransaction.h"
#include "Document.h"
#include "Application.h"
#include "DocumentObject.h"
Expand Down Expand Up @@ -1831,7 +1832,8 @@ void Document::writeObjects(const std::vector<App::DocumentObject*>& obj,

if(!isExporting(0)) {
for(auto o : obj) {
const auto &outList = o->getOutList(DocumentObject::OutListNoHidden);
const auto &outList = o->getOutList(DocumentObject::OutListNoHidden
| DocumentObject::OutListNoXLinked);
writer.Stream() << writer.ind()
<< "<" FC_ELEMENT_OBJECT_DEPS " " FC_ATTR_DEP_OBJ_NAME "=\""
<< o->getNameInDocument() << "\" " FC_ATTR_DEP_COUNT "=\"" << outList.size();
Expand Down Expand Up @@ -3764,6 +3766,8 @@ void Document::removeObject(const char* sName)
return;
}

TransactionLocker tlock;

_checkTransaction(pos->second,0,__LINE__);

#if 0
Expand Down Expand Up @@ -3865,6 +3869,8 @@ void Document::_removeObject(DocumentObject* pcObject)
return;
}

TransactionLocker tlock;

// TODO Refactoring: share code with Document::removeObject() (2015-09-01, Fat-Zer)
_checkTransaction(pcObject,0,__LINE__);

Expand Down
14 changes: 12 additions & 2 deletions src/App/DocumentObject.cpp
Expand Up @@ -284,14 +284,24 @@ void DocumentObject::getOutList(int options, std::vector<DocumentObject*> &res)
std::vector<Property*> props;
getPropertyList(props);
bool noHidden = !!(options & OutListNoHidden);
bool noXLinked = !!(options & OutListNoXLinked);
std::size_t size = res.size();
for(auto prop : props) {
auto link = dynamic_cast<PropertyLinkBase*>(prop);
if(link && (!noXLinked || !PropertyXLink::supportXLink(prop)))
if(link)
link->getLinks(res,noHidden);
}
if(!(options & OutListNoExpression))
ExpressionEngine.getLinks(res);

if(options & OutListNoXLinked) {
for(auto it=res.begin()+size;it!=res.end();) {
auto obj = *it;
if(obj && obj->getDocument()!=getDocument())
it = res.erase(it);
else
++it;
}
}
}

std::vector<App::DocumentObject*> DocumentObject::getOutListOfProperty(App::Property* prop) const
Expand Down

0 comments on commit ca7b587

Please sign in to comment.