diff --git a/src/App/Application.cpp b/src/App/Application.cpp index 6b83908bda..3f32c1780e 100644 --- a/src/App/Application.cpp +++ b/src/App/Application.cpp @@ -1889,7 +1889,7 @@ void Application::initConfig(int argc, char ** argv) Branding brand; QString binDir = QString::fromUtf8((mConfig["AppHomePath"] + "bin").c_str()); QFileInfo fi(binDir, QString::fromLatin1("branding.xml")); - if (brand.readFile(fi.absoluteFilePath())) { + if (fi.exists() && brand.readFile(fi.absoluteFilePath())) { Branding::XmlConfig cfg = brand.getUserDefines(); for (Branding::XmlConfig::iterator it = cfg.begin(); it != cfg.end(); ++it) { App::Application::Config()[it.key()] = it.value(); diff --git a/src/Base/Console.cpp b/src/Base/Console.cpp index 31a1b90d81..bd7fcfde09 100644 --- a/src/Base/Console.cpp +++ b/src/Base/Console.cpp @@ -126,8 +126,6 @@ ConsoleSingleton::ConsoleSingleton(void) ,_defaultLogLevel(FC_LOGLEVEL_MSG) #endif { - // make sure this object is part of the main thread - ConsoleOutput::getInstance(); } ConsoleSingleton::~ConsoleSingleton() @@ -233,6 +231,11 @@ bool ConsoleSingleton::IsMsgTypeEnabled(const char* sObs, FreeCAD_ConsoleMsgType void ConsoleSingleton::SetConnectionMode(ConnectionMode mode) { connectionMode = mode; + + // make sure this method gets called from the main thread + if (connectionMode == Queued) { + ConsoleOutput::getInstance(); + } } /** Prints a Message diff --git a/src/Main/FreeCADGuiPy.cpp b/src/Main/FreeCADGuiPy.cpp index 3d7b5488a0..a1d2079743 100644 --- a/src/Main/FreeCADGuiPy.cpp +++ b/src/Main/FreeCADGuiPy.cpp @@ -109,6 +109,9 @@ FreeCADGui_showMainWindow(PyObject * /*self*/, PyObject *args) #if (QT_VERSION >= QT_VERSION_CHECK(5, 9, 0)) QApplication::setAttribute(Qt::AA_ShareOpenGLContexts); #endif + // This only works well if the QApplication is the very first created instance + // of a QObject. Otherwise the application lives in a different thread than the + // main thread which will cause hazardous behaviour. QtApplication app(argc, argv); if (setupMainWindow()) { app.exec();