From 881cf7420dccf3c43837390efa9cded7b24836a2 Mon Sep 17 00:00:00 2001 From: azv Date: Thu, 24 Nov 2016 08:28:48 +0300 Subject: [PATCH] Workaround for Debian 6.0 (issues #1868 and #1878) Correction. --- src/Model/Model_Session.cpp | 19 +++++++++++++++++++ src/Model/Model_Session.h | 3 +++ src/ModelAPI/ModelAPI_Session.h | 3 +++ src/PythonAPI/model/sketcher/__init__.py | 8 ++------ 4 files changed, 27 insertions(+), 6 deletions(-) diff --git a/src/Model/Model_Session.cpp b/src/Model/Model_Session.cpp index 790664f05..a68d98b0c 100644 --- a/src/Model/Model_Session.cpp +++ b/src/Model/Model_Session.cpp @@ -472,3 +472,22 @@ int Model_Session::transactionID() { return ROOT_DOC->transactionID(); } + +void Model_Session::forceLoadPlugin(const std::string& thePluginName) +{ + // load all information about plugins, features and attributes + LoadPluginsInfo(); + + // store name of current plugin for further restoring, + // because forceLoadPlugin may be called while loading another plugin + std::string aCurrentPluginName = myCurrentPluginName; + + myCurrentPluginName = thePluginName; + if (myPluginObjs.find(myCurrentPluginName) == myPluginObjs.end()) { + // load plugin library if not yet done + Config_ModuleReader::loadPlugin(myCurrentPluginName); + } + + // restore current plugin + myCurrentPluginName = aCurrentPluginName; +} diff --git a/src/Model/Model_Session.h b/src/Model/Model_Session.h index 2afa84a26..d9f9f2c2d 100644 --- a/src/Model/Model_Session.h +++ b/src/Model/Model_Session.h @@ -128,6 +128,9 @@ class Model_Session : public ModelAPI_Session, public Events_Listener /// Returns the global identifier of the current transaction (needed for the update algo) MODEL_EXPORT virtual int transactionID(); + /// Load plugin by its name + MODEL_EXPORT virtual void forceLoadPlugin(const std::string& thePluginName); + protected: /// Loads (if not done yet) the information about the features and plugins void LoadPluginsInfo(); diff --git a/src/ModelAPI/ModelAPI_Session.h b/src/ModelAPI/ModelAPI_Session.h index 40984fb03..cc6987bd3 100644 --- a/src/ModelAPI/ModelAPI_Session.h +++ b/src/ModelAPI/ModelAPI_Session.h @@ -115,6 +115,9 @@ class MODELAPI_EXPORT ModelAPI_Session /// Returns the global identifier of the current transaction (needed for the update algo) virtual int transactionID() = 0; + /// Load plugin by its name + virtual void forceLoadPlugin(const std::string& thePluginName) = 0; + protected: /// Sets the session interface implementation (once per application launch) static void setSession(std::shared_ptr theManager); diff --git a/src/PythonAPI/model/sketcher/__init__.py b/src/PythonAPI/model/sketcher/__init__.py index 2edb1d226..9231f5d32 100644 --- a/src/PythonAPI/model/sketcher/__init__.py +++ b/src/PythonAPI/model/sketcher/__init__.py @@ -7,13 +7,9 @@ It is kept, because SketchPlugin should be loaded before SketchAPI is first used. Otherwise, the runtime error will be generated while some static inline methods are broken. """ -from ModelAPI import * +from ModelAPI import ModelAPI_Session aSession = ModelAPI_Session.get() -aDocument = aSession.moduleDocument() -aSession.startOperation() -aDocument.addFeature("Sketch") -aSession.finishOperation() -aSession.abortOperation() +aSession.forceLoadPlugin("SketchPlugin") # DEBIAN 6.0 WORKAROUND FINISH from SketchAPI import addSketch -- 2.30.2