@@ -34,6 +34,7 @@
|
||||
# define WINVER 0x502 // needed for SetDllDirectory
|
||||
# include <Windows.h>
|
||||
# endif
|
||||
# include <boost/algorithm/string.hpp>
|
||||
# include <boost/program_options.hpp>
|
||||
# include <boost/date_time/posix_time/posix_time.hpp>
|
||||
# include <boost/scope_exit.hpp>
|
||||
@@ -1339,18 +1340,15 @@ void Application::changeImportModule(const char* filter, const char* oldModuleNa
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::string> Application::getImportModules(const char* extension) const
|
||||
std::vector<std::string> Application::getImportModules(const std::string& extension) const
|
||||
{
|
||||
std::vector<std::string> modules;
|
||||
for (const auto & it : _mImportTypes) {
|
||||
const std::vector<std::string>& types = it.types;
|
||||
for (const auto & jt : types) {
|
||||
#ifdef __GNUC__
|
||||
if (strcasecmp(extension, jt.c_str()) == 0)
|
||||
#else
|
||||
if (_stricmp(extension, jt.c_str()) == 0)
|
||||
#endif
|
||||
if (boost::iequals(extension, jt)) {
|
||||
modules.push_back(it.module);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1369,16 +1367,13 @@ std::vector<std::string> Application::getImportModules() const
|
||||
return modules;
|
||||
}
|
||||
|
||||
std::vector<std::string> Application::getImportTypes(const char* Module) const
|
||||
std::vector<std::string> Application::getImportTypes(const std::string& Module) const
|
||||
{
|
||||
std::vector<std::string> types;
|
||||
for (const auto & it : _mImportTypes) {
|
||||
#ifdef __GNUC__
|
||||
if (strcasecmp(Module,it.module.c_str()) == 0)
|
||||
#else
|
||||
if (_stricmp(Module,it.module.c_str()) == 0)
|
||||
#endif
|
||||
if (boost::iequals(Module, it.module)) {
|
||||
types.insert(types.end(), it.types.begin(), it.types.end());
|
||||
}
|
||||
}
|
||||
|
||||
return types;
|
||||
@@ -1397,18 +1392,15 @@ std::vector<std::string> Application::getImportTypes() const
|
||||
return types;
|
||||
}
|
||||
|
||||
std::map<std::string, std::string> Application::getImportFilters(const char* extension) const
|
||||
std::map<std::string, std::string> Application::getImportFilters(const std::string& extension) const
|
||||
{
|
||||
std::map<std::string, std::string> moduleFilter;
|
||||
for (const auto & it : _mImportTypes) {
|
||||
const std::vector<std::string>& types = it.types;
|
||||
for (const auto & jt : types) {
|
||||
#ifdef __GNUC__
|
||||
if (strcasecmp(extension,jt.c_str()) == 0)
|
||||
#else
|
||||
if (_stricmp(extension,jt.c_str()) == 0)
|
||||
#endif
|
||||
if (boost::iequals(extension, jt)) {
|
||||
moduleFilter[it.filter] = it.module;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1464,18 +1456,15 @@ void Application::changeExportModule(const char* filter, const char* oldModuleNa
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::string> Application::getExportModules(const char* extension) const
|
||||
std::vector<std::string> Application::getExportModules(const std::string& extension) const
|
||||
{
|
||||
std::vector<std::string> modules;
|
||||
for (const auto & it : _mExportTypes) {
|
||||
const std::vector<std::string>& types = it.types;
|
||||
for (const auto & jt : types) {
|
||||
#ifdef __GNUC__
|
||||
if (strcasecmp(extension,jt.c_str()) == 0)
|
||||
#else
|
||||
if (_stricmp(extension,jt.c_str()) == 0)
|
||||
#endif
|
||||
if (boost::iequals(extension, jt)) {
|
||||
modules.push_back(it.module);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1494,16 +1483,13 @@ std::vector<std::string> Application::getExportModules() const
|
||||
return modules;
|
||||
}
|
||||
|
||||
std::vector<std::string> Application::getExportTypes(const char* Module) const
|
||||
std::vector<std::string> Application::getExportTypes(const std::string& Module) const
|
||||
{
|
||||
std::vector<std::string> types;
|
||||
for (const auto & it : _mExportTypes) {
|
||||
#ifdef __GNUC__
|
||||
if (strcasecmp(Module,it.module.c_str()) == 0)
|
||||
#else
|
||||
if (_stricmp(Module,it.module.c_str()) == 0)
|
||||
#endif
|
||||
if (boost::iequals(Module, it.module)) {
|
||||
types.insert(types.end(), it.types.begin(), it.types.end());
|
||||
}
|
||||
}
|
||||
|
||||
return types;
|
||||
@@ -1522,18 +1508,15 @@ std::vector<std::string> Application::getExportTypes() const
|
||||
return types;
|
||||
}
|
||||
|
||||
std::map<std::string, std::string> Application::getExportFilters(const char* extension) const
|
||||
std::map<std::string, std::string> Application::getExportFilters(const std::string& extension) const
|
||||
{
|
||||
std::map<std::string, std::string> moduleFilter;
|
||||
for (const auto & it : _mExportTypes) {
|
||||
const std::vector<std::string>& types = it.types;
|
||||
for (const auto & jt : types) {
|
||||
#ifdef __GNUC__
|
||||
if (strcasecmp(extension,jt.c_str()) == 0)
|
||||
#else
|
||||
if (_stricmp(extension,jt.c_str()) == 0)
|
||||
#endif
|
||||
if (boost::iequals(extension, jt)) {
|
||||
moduleFilter[it.filter] = it.module;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2847,8 +2830,7 @@ std::list<std::string> Application::processFiles(const std::list<std::string>& f
|
||||
}
|
||||
}
|
||||
else {
|
||||
std::string ext = file.extension();
|
||||
std::vector<std::string> mods = GetApplication().getImportModules(ext.c_str());
|
||||
std::vector<std::string> mods = GetApplication().getImportModules(file.extension());
|
||||
if (!mods.empty()) {
|
||||
std::string escapedstr = Base::Tools::escapedUnicodeFromUtf8(file.filePath().c_str());
|
||||
escapedstr = Base::Tools::escapeEncodeFilename(escapedstr);
|
||||
@@ -2905,9 +2887,8 @@ void Application::processCmdLineFiles()
|
||||
output = Base::Tools::escapeEncodeFilename(output);
|
||||
|
||||
const Base::FileInfo fi(output);
|
||||
const std::string ext = fi.extension();
|
||||
try {
|
||||
const std::vector<std::string> mods = GetApplication().getExportModules(ext.c_str());
|
||||
const std::vector<std::string> mods = GetApplication().getExportModules(fi.extension());
|
||||
if (!mods.empty()) {
|
||||
Base::Interpreter().loadModule(mods.front().c_str());
|
||||
Base::Interpreter().runStringArg("import %s",mods.front().c_str());
|
||||
@@ -3702,24 +3683,23 @@ void Application::getVerboseCommonInfo(QTextStream& str, const std::map<std::str
|
||||
#endif
|
||||
str << "xerces-c " << fcXercescVersion << ", ";
|
||||
|
||||
const char* cmd = "import ifcopenshell\n"
|
||||
"version = ifcopenshell.version";
|
||||
PyObject * ifcopenshellVer = nullptr;
|
||||
|
||||
try {
|
||||
ifcopenshellVer = Base::Interpreter().getValue(cmd, "version");
|
||||
}
|
||||
catch (const Base::Exception& e) {
|
||||
Base::Console().log("%s (safe to ignore, unless using the BIM workbench and IFC).\n", e.what());
|
||||
}
|
||||
|
||||
if (ifcopenshellVer) {
|
||||
const char* ifcopenshellVerAsStr = PyUnicode_AsUTF8(ifcopenshellVer);
|
||||
|
||||
if (ifcopenshellVerAsStr) {
|
||||
str << "IfcOpenShell " << ifcopenshellVerAsStr << ", ";
|
||||
Base::PyGILStateLocker lock;
|
||||
Py::Module module(PyImport_ImportModule("ifcopenshell"), true);
|
||||
if (!module.isNull() && module.hasAttr("version")) {
|
||||
Py::String version(module.getAttr("version"));
|
||||
auto ver_str = static_cast<std::string>(version);
|
||||
str << "IfcOpenShell " << ver_str.c_str() << ", ";
|
||||
}
|
||||
Py_DECREF(ifcopenshellVer);
|
||||
else {
|
||||
Base::Console().log("Module 'ifcopenshell' not found (safe to ignore, unless using "
|
||||
"the BIM workbench and IFC).\n");
|
||||
}
|
||||
}
|
||||
catch (const Py::Exception&) {
|
||||
Base::PyGILStateLocker lock;
|
||||
Base::PyException e;
|
||||
Base::Console().log("%s\n", e.what());
|
||||
}
|
||||
|
||||
#if defined(HAVE_OCC_VERSION)
|
||||
|
||||
@@ -561,7 +561,7 @@ public:
|
||||
*
|
||||
* @param[in] extension The file type extension.
|
||||
*/
|
||||
std::vector<std::string> getImportModules(const char* extension) const;
|
||||
std::vector<std::string> getImportModules(const std::string& extension) const;
|
||||
|
||||
/// Get a list of all import modules.
|
||||
std::vector<std::string> getImportModules() const;
|
||||
@@ -572,7 +572,7 @@ public:
|
||||
* @param[in] Module The module name.
|
||||
* @return A list of file types (extensions) supported by the module.
|
||||
*/
|
||||
std::vector<std::string> getImportTypes(const char* Module) const;
|
||||
std::vector<std::string> getImportTypes(const std::string& Module) const;
|
||||
|
||||
/// Get a list of all import filetypes represented as extensions.
|
||||
std::vector<std::string> getImportTypes() const;
|
||||
@@ -583,7 +583,7 @@ public:
|
||||
* @param[in] extension The file type represented by its extension.
|
||||
* @return A map of filter description to module name.
|
||||
*/
|
||||
std::map<std::string, std::string> getImportFilters(const char* extension) const;
|
||||
std::map<std::string, std::string> getImportFilters(const std::string& extension) const;
|
||||
|
||||
/// Get a mapping of all import filters to their modules.
|
||||
std::map<std::string, std::string> getImportFilters() const;
|
||||
@@ -605,7 +605,7 @@ public:
|
||||
*
|
||||
* @copydetails getImportModules
|
||||
*/
|
||||
std::vector<std::string> getExportModules(const char* extension) const;
|
||||
std::vector<std::string> getExportModules(const std::string& extension) const;
|
||||
|
||||
/// Get a list of all export modules.
|
||||
std::vector<std::string> getExportModules() const;
|
||||
@@ -613,9 +613,9 @@ public:
|
||||
/**
|
||||
* @brief Get a list of filetypes that are supported by a module for export.
|
||||
*
|
||||
* @copydetails App::Application::getImportTypes(const char*) const
|
||||
* @copydetails App::Application::getImportTypes(const std::string&) const
|
||||
*/
|
||||
std::vector<std::string> getExportTypes(const char* Module) const;
|
||||
std::vector<std::string> getExportTypes(const std::string& Module) const;
|
||||
|
||||
/// Get a list of all export filetypes.
|
||||
std::vector<std::string> getExportTypes() const;
|
||||
@@ -623,9 +623,9 @@ public:
|
||||
/**
|
||||
* @brief Get the export filters with modules of a given filetype.
|
||||
*
|
||||
* @copydetails App::Application::getImportFilters(const char*) const
|
||||
* @copydetails App::Application::getImportFilters(const std::string&) const
|
||||
*/
|
||||
std::map<std::string, std::string> getExportFilters(const char* extension) const;
|
||||
std::map<std::string, std::string> getExportFilters(const std::string& extension) const;
|
||||
|
||||
/// Get a mapping of all export filters to their modules.
|
||||
std::map<std::string, std::string> getExportFilters() const;
|
||||
|
||||
@@ -760,7 +760,7 @@ PyObject* Application::sGetExportType(PyObject* /*self*/, PyObject* args)
|
||||
Py::Dict dict;
|
||||
std::vector<std::string> types = GetApplication().getExportTypes();
|
||||
for (const auto& it : types) {
|
||||
std::vector<std::string> modules = GetApplication().getExportModules(it.c_str());
|
||||
std::vector<std::string> modules = GetApplication().getExportModules(it);
|
||||
if (modules.empty()) {
|
||||
dict.setItem(it.c_str(), Py::None());
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
#include <sstream>
|
||||
#include <stack>
|
||||
#include <string>
|
||||
#include <fmt/format.h>
|
||||
|
||||
#include <App/Application.h>
|
||||
#include <App/DocumentObject.h>
|
||||
@@ -3786,14 +3787,17 @@ Expression * App::ExpressionParser::parse(const App::DocumentObject *owner, cons
|
||||
// run the parser
|
||||
int result = ExpressionParser::ExpressionParser_yyparse ();
|
||||
|
||||
if (result != 0)
|
||||
throw ParserError("Failed to parse expression.");
|
||||
if (result != 0) {
|
||||
throw ParserError(fmt::format("Failed to parse expression '{}'", buffer));
|
||||
}
|
||||
|
||||
if (!ScanResult)
|
||||
throw ParserError("Unknown error in expression");
|
||||
if (!ScanResult) {
|
||||
throw ParserError(fmt::format("Unknown error in expression '{}'", buffer));
|
||||
}
|
||||
|
||||
if (valueExpression)
|
||||
if (valueExpression) {
|
||||
return ScanResult;
|
||||
}
|
||||
else {
|
||||
delete ScanResult;
|
||||
throw Expression::Exception("Expression can not evaluate to a value.");
|
||||
|
||||
@@ -50,6 +50,7 @@
|
||||
#include <sstream>
|
||||
|
||||
// STL
|
||||
#include <array>
|
||||
#include <bitset>
|
||||
#include <chrono>
|
||||
#if defined(FC_OS_WIN32)
|
||||
|
||||
@@ -243,6 +243,9 @@ bool ProjectFile::loadDocument()
|
||||
try {
|
||||
Base::StdInputSource inputSource(*str, stdFile.c_str());
|
||||
parser->parse(inputSource);
|
||||
if (parser->getErrorCount() > 0) {
|
||||
return false;
|
||||
}
|
||||
xmlDocument = parser->adoptDocument();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
***************************************************************************/
|
||||
|
||||
#include <cassert>
|
||||
#include <array>
|
||||
#include <tuple>
|
||||
|
||||
#include <atomic>
|
||||
#include <Base/Tools.h>
|
||||
@@ -114,36 +116,35 @@ std::string Property::getFileName(const char* postfix, const char* prefix) const
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
// clang-format off
|
||||
static constexpr auto mapProps = std::to_array<std::tuple<Property::Status, PropertyType>>({
|
||||
{App::Property::PropReadOnly, Prop_ReadOnly},
|
||||
{App::Property::PropHidden, Prop_Hidden},
|
||||
{App::Property::PropOutput, Prop_Output},
|
||||
{App::Property::PropTransient, Prop_Transient},
|
||||
{App::Property::PropNoRecompute, Prop_NoRecompute},
|
||||
{App::Property::PropNoPersist, Prop_NoPersist}
|
||||
});
|
||||
// clang-format on
|
||||
|
||||
short Property::getType() const
|
||||
{
|
||||
short type = 0;
|
||||
#define GET_PTYPE(_name) \
|
||||
do { \
|
||||
if (testStatus(App::Property::Prop##_name)) \
|
||||
type |= Prop_##_name; \
|
||||
} while (0)
|
||||
GET_PTYPE(ReadOnly);
|
||||
GET_PTYPE(Hidden);
|
||||
GET_PTYPE(Output);
|
||||
GET_PTYPE(Transient);
|
||||
GET_PTYPE(NoRecompute);
|
||||
GET_PTYPE(NoPersist);
|
||||
for (const auto& [propertyStatus, propertyType] : mapProps) {
|
||||
if (testStatus(propertyStatus)) {
|
||||
type |= propertyType;
|
||||
}
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
void Property::syncType(unsigned type)
|
||||
{
|
||||
#define SYNC_PTYPE(_name) \
|
||||
do { \
|
||||
if (type & Prop_##_name) \
|
||||
StatusBits.set((size_t)Prop##_name); \
|
||||
} while (0)
|
||||
SYNC_PTYPE(ReadOnly);
|
||||
SYNC_PTYPE(Transient);
|
||||
SYNC_PTYPE(Hidden);
|
||||
SYNC_PTYPE(Output);
|
||||
SYNC_PTYPE(NoRecompute);
|
||||
SYNC_PTYPE(NoPersist);
|
||||
for (const auto& [propertyStatus, propertyType] : mapProps) {
|
||||
if (type & propertyType) {
|
||||
StatusBits.set((size_t)propertyStatus);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const char* Property::getGroup() const
|
||||
|
||||
@@ -467,21 +467,36 @@ void PropertyExpressionEngine::afterRestore()
|
||||
ObjectIdentifier::DocumentMapper mapper(this->_DocMap);
|
||||
|
||||
for (auto& info : *restoredExpressions) {
|
||||
ObjectIdentifier path = ObjectIdentifier::parse(docObj, info.path);
|
||||
if (!info.expr.empty()) {
|
||||
std::shared_ptr<Expression> expression(
|
||||
Expression::parse(docObj, info.expr.c_str()));
|
||||
if (expression) {
|
||||
expression->comment = std::move(info.comment);
|
||||
}
|
||||
setValue(path, expression);
|
||||
}
|
||||
tryRestoreExpression(docObj, info);
|
||||
}
|
||||
signaller.tryInvoke();
|
||||
}
|
||||
restoredExpressions.reset();
|
||||
}
|
||||
|
||||
void PropertyExpressionEngine::tryRestoreExpression(DocumentObject* docObj,
|
||||
const RestoredExpression& info)
|
||||
{
|
||||
try {
|
||||
ObjectIdentifier path = ObjectIdentifier::parse(docObj, info.path);
|
||||
if (!info.expr.empty()) {
|
||||
std::shared_ptr<Expression> expression(
|
||||
Expression::parse(docObj, info.expr));
|
||||
if (expression) {
|
||||
expression->comment = info.comment;
|
||||
}
|
||||
setValue(path, expression);
|
||||
}
|
||||
}
|
||||
catch (const Base::Exception& e) {
|
||||
FC_ERR("Failed to restore " << docObj->getFullName()
|
||||
<< '.'
|
||||
<< getName()
|
||||
<< ": "
|
||||
<< e.what());
|
||||
}
|
||||
}
|
||||
|
||||
void PropertyExpressionEngine::onContainerRestored()
|
||||
{
|
||||
Base::FlagToggler<bool> flag(restoring);
|
||||
|
||||
@@ -244,6 +244,8 @@ private:
|
||||
* into the actual map */
|
||||
std::unique_ptr<std::vector<RestoredExpression>> restoredExpressions;
|
||||
|
||||
void tryRestoreExpression(DocumentObject* docObj, const RestoredExpression& info);
|
||||
|
||||
struct Private;
|
||||
std::unique_ptr<Private> pimpl;
|
||||
|
||||
|
||||
@@ -4281,14 +4281,12 @@ void PropertyXLink::Restore(Base::XMLReader& reader)
|
||||
name = reader.getAttribute<const char*>("name");
|
||||
}
|
||||
|
||||
assert(getContainer()->isDerivedFrom<App::DocumentObject>());
|
||||
DocumentObject* object = nullptr;
|
||||
if (!name.empty() && file.empty()) {
|
||||
DocumentObject* parent = static_cast<DocumentObject*>(getContainer());
|
||||
Document* document = parent->getDocument();
|
||||
object = document ? document->getObject(name.c_str()) : nullptr;
|
||||
if (!object) {
|
||||
if (reader.isVerbose()) {
|
||||
if (auto parent = freecad_cast<DocumentObject*>(getContainer())) {
|
||||
Document* document = parent->getDocument();
|
||||
object = document ? document->getObject(name.c_str()) : nullptr;
|
||||
if (!object && reader.isVerbose()) {
|
||||
FC_WARN("Lost link to '" << name
|
||||
<< "' while loading, maybe "
|
||||
"an object was not loaded correctly");
|
||||
|
||||
@@ -3194,6 +3194,7 @@ const Base::Color& PropertyMaterialList::getDiffuseColor(int index) const
|
||||
std::vector<Base::Color> PropertyMaterialList::getDiffuseColors() const
|
||||
{
|
||||
std::vector<Base::Color> list;
|
||||
list.reserve(_lValueList.size());
|
||||
for (auto& material : _lValueList) {
|
||||
list.push_back(material.diffuseColor);
|
||||
}
|
||||
@@ -3244,6 +3245,7 @@ float PropertyMaterialList::getTransparency(int index) const
|
||||
std::vector<float> PropertyMaterialList::getTransparencies() const
|
||||
{
|
||||
std::vector<float> list;
|
||||
list.reserve(_lValueList.size());
|
||||
for (auto& material : _lValueList) {
|
||||
list.push_back(material.transparency);
|
||||
}
|
||||
|
||||
@@ -147,18 +147,15 @@ void Transaction::changeProperty(TransactionalObject* Obj,
|
||||
auto& index = _Objects.get<1>();
|
||||
auto pos = index.find(Obj);
|
||||
|
||||
TransactionObject* To;
|
||||
|
||||
if (pos != index.end()) {
|
||||
To = pos->second;
|
||||
auto To = pos->second;
|
||||
changeFunc(To);
|
||||
}
|
||||
else {
|
||||
To = TransactionFactory::instance().createTransaction(Obj->getTypeId());
|
||||
else if (auto To = TransactionFactory::instance().createTransaction(Obj->getTypeId())) {
|
||||
To->status = TransactionObject::Chn;
|
||||
index.emplace(Obj, To);
|
||||
changeFunc(To);
|
||||
}
|
||||
|
||||
changeFunc(To);
|
||||
}
|
||||
|
||||
void Transaction::renameProperty(TransactionalObject* Obj, const Property* pcProp, const char* oldName)
|
||||
@@ -230,8 +227,7 @@ void Transaction::addObjectNew(TransactionalObject* Obj)
|
||||
seq.relocate(seq.end(), _Objects.project<0>(pos));
|
||||
}
|
||||
}
|
||||
else {
|
||||
TransactionObject* To = TransactionFactory::instance().createTransaction(Obj->getTypeId());
|
||||
else if (auto To = TransactionFactory::instance().createTransaction(Obj->getTypeId())) {
|
||||
To->status = TransactionObject::New;
|
||||
To->_NameInDocument = Obj->detachFromDocument();
|
||||
index.emplace(Obj, To);
|
||||
@@ -252,8 +248,7 @@ void Transaction::addObjectDel(const TransactionalObject* Obj)
|
||||
else if (pos != index.end() && pos->second->status == TransactionObject::Chn) {
|
||||
pos->second->status = TransactionObject::Del;
|
||||
}
|
||||
else {
|
||||
TransactionObject* To = TransactionFactory::instance().createTransaction(Obj->getTypeId());
|
||||
else if (auto To = TransactionFactory::instance().createTransaction(Obj->getTypeId())) {
|
||||
To->status = TransactionObject::Del;
|
||||
index.emplace(Obj, To);
|
||||
}
|
||||
@@ -264,18 +259,15 @@ void Transaction::addObjectChange(const TransactionalObject* Obj, const Property
|
||||
auto& index = _Objects.get<1>();
|
||||
auto pos = index.find(Obj);
|
||||
|
||||
TransactionObject* To;
|
||||
|
||||
if (pos != index.end()) {
|
||||
To = pos->second;
|
||||
auto To = pos->second;
|
||||
To->setProperty(Prop);
|
||||
}
|
||||
else {
|
||||
To = TransactionFactory::instance().createTransaction(Obj->getTypeId());
|
||||
else if (auto To = TransactionFactory::instance().createTransaction(Obj->getTypeId())) {
|
||||
To->status = TransactionObject::Chn;
|
||||
index.emplace(Obj, To);
|
||||
To->setProperty(Prop);
|
||||
}
|
||||
|
||||
To->setProperty(Prop);
|
||||
}
|
||||
|
||||
|
||||
@@ -556,13 +548,12 @@ void TransactionFactory::addProducer(const Base::Type& type, Base::AbstractProdu
|
||||
*/
|
||||
TransactionObject* TransactionFactory::createTransaction(const Base::Type& type) const
|
||||
{
|
||||
std::map<Base::Type, Base::AbstractProducer*>::const_iterator it;
|
||||
for (it = producers.begin(); it != producers.end(); ++it) {
|
||||
if (type.isDerivedFrom(it->first)) {
|
||||
return static_cast<TransactionObject*>(it->second->Produce());
|
||||
for (const auto& it : producers) {
|
||||
if (type.isDerivedFrom(it.first)) {
|
||||
return static_cast<TransactionObject*>(it.second->Produce());
|
||||
}
|
||||
}
|
||||
|
||||
assert(0);
|
||||
Base::Console().log("Cannot create transaction object from %s\n", type.getName());
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -1098,12 +1098,12 @@ SelectModule::Dict SelectModule::exportHandler(const QStringList& fileNames, con
|
||||
QFileInfo fi(fileName);
|
||||
QString ext = fi.completeSuffix().toLower();
|
||||
std::map<std::string, std::string> filters = App::GetApplication().getExportFilters(
|
||||
ext.toLatin1()
|
||||
ext.toStdString()
|
||||
);
|
||||
|
||||
if (filters.empty()) {
|
||||
ext = fi.suffix().toLower();
|
||||
filters = App::GetApplication().getExportFilters(ext.toLatin1());
|
||||
filters = App::GetApplication().getExportFilters(ext.toStdString());
|
||||
}
|
||||
|
||||
fileExtension[ext].push_back(fileName);
|
||||
@@ -1168,12 +1168,12 @@ SelectModule::Dict SelectModule::importHandler(const QStringList& fileNames, con
|
||||
QFileInfo fi(fileName);
|
||||
QString ext = fi.completeSuffix().toLower();
|
||||
std::map<std::string, std::string> filters = App::GetApplication().getImportFilters(
|
||||
ext.toLatin1()
|
||||
ext.toStdString()
|
||||
);
|
||||
|
||||
if (filters.empty()) {
|
||||
ext = fi.suffix().toLower();
|
||||
filters = App::GetApplication().getImportFilters(ext.toLatin1());
|
||||
filters = App::GetApplication().getImportFilters(ext.toStdString());
|
||||
}
|
||||
|
||||
fileExtension[ext].push_back(fileName);
|
||||
|
||||
@@ -2453,10 +2453,10 @@ void MainWindow::loadUrls(App::Document* doc, const QList<QUrl>& urls)
|
||||
info.setFile(info.symLinkTarget());
|
||||
}
|
||||
std::vector<std::string> module = App::GetApplication().getImportModules(
|
||||
info.completeSuffix().toLatin1()
|
||||
info.completeSuffix().toStdString()
|
||||
);
|
||||
if (module.empty()) {
|
||||
module = App::GetApplication().getImportModules(info.suffix().toLatin1());
|
||||
module = App::GetApplication().getImportModules(info.suffix().toStdString());
|
||||
}
|
||||
if (!module.empty()) {
|
||||
// ok, we support files with this extension
|
||||
|
||||
Reference in New Issue
Block a user