Core: add Ifcopenshell version in about info clipboard (#19264)

* Core: return information about ifcopenshell version in About info clipboard

* Core: remove whitespace introduced by mistake

* Core: handle case where ifcopenshell is not installed

* Core: remove colon for consistency with other library versions

* Core: change type of cmd to const char* to avoid allocating memory

* Core: make failure to import ifcopenshell a debug message

* Core: fix non-existing Debug message with DeveloperWarning

* Core: go back to Log() to show info about non-installed ifcopenshell
This commit is contained in:
Furgo
2025-02-05 10:18:54 +01:00
committed by GitHub
parent be7b1acefd
commit 81040d684d

View File

@@ -45,6 +45,7 @@
#include <App/Application.h>
#include <App/Metadata.h>
#include <Base/Console.h>
#include <Base/Interpreter.h>
#include <CXX/WrapPython.h>
#include <boost/filesystem.hpp>
@@ -652,6 +653,28 @@ void AboutDialog::copyToClipboard()
str << "Qt " << QT_VERSION_STR << ", ";
str << "Coin " << COIN_VERSION << ", ";
str << "Vtk " << fcVtkVersion << ", ";
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 << ", ";
Py_DECREF(ifcopenshellVerAsStr);
}
Py_DECREF(ifcopenshellVer);
}
#if defined(HAVE_OCC_VERSION)
str << "OCC " << OCC_VERSION_MAJOR << "." << OCC_VERSION_MINOR << "." << OCC_VERSION_MAINTENANCE
#ifdef OCC_VERSION_DEVELOPMENT