mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-10-09 13:34:14 +02:00
Merge pull request #1183 from ispyisail/fix/headless-settings-dir
Linux build and tests / Build and test (Qt 6, Debug) (push) Failing after 3m54s
Linux build and tests / Build and test (Qt 6, Debug) (push) Failing after 3m54s
Fix the MCP server's elements_dir on Windows (QET_SETTINGS_DIR)
This commit is contained in:
@@ -35,6 +35,7 @@
|
||||
#include <QDomImplementation>
|
||||
#include <QFont>
|
||||
|
||||
#include <QSettings>
|
||||
#include <QStyleFactory>
|
||||
#include <QtConcurrentRun>
|
||||
|
||||
@@ -103,6 +104,19 @@ int main(int argc, char **argv)
|
||||
QCoreApplication::setOrganizationDomain("qelectrotech.org");
|
||||
QCoreApplication::setApplicationName("QElectroTech");
|
||||
|
||||
// QET_SETTINGS_DIR keeps the settings in an INI file in that folder,
|
||||
// <folder>/QElectroTech/QElectroTech.ini, instead of the registry on
|
||||
// Windows, the system preferences on macOS or ~/.config on Linux. A tool
|
||||
// running QElectroTech headlessly (misc/qet-mcp) can then give each run
|
||||
// its own settings, and point it at an element collection, on every
|
||||
// system (issue #1178). Set before anything reads a setting.
|
||||
const QString settings_dir = qEnvironmentVariable("QET_SETTINGS_DIR");
|
||||
if (!settings_dir.isEmpty()) {
|
||||
QSettings::setDefaultFormat(QSettings::IniFormat);
|
||||
QSettings::setPath(QSettings::IniFormat, QSettings::UserScope, settings_dir);
|
||||
QSettings::setPath(QSettings::IniFormat, QSettings::SystemScope, settings_dir);
|
||||
}
|
||||
|
||||
// Refuse invalid data when building QDom documents instead of
|
||||
// serializing malformed XML (CVE-2026-15037). This is the default
|
||||
// from Qt 6.12 on; opt in explicitly for older Qt 5/6.
|
||||
|
||||
Reference in New Issue
Block a user