diff --git a/sources/machine_info.h b/sources/machine_info.h index 04f074f6d..58866184b 100644 --- a/sources/machine_info.h +++ b/sources/machine_info.h @@ -75,11 +75,11 @@ class MachineInfo { struct Screen { - int32_t count; - int32_t width[10]; - int32_t height[10]; - int32_t Max_width; - int32_t Max_height; + int32_t count = 0; + int32_t width[10] = {}; + int32_t height[10]= {}; + int32_t Max_width = 0; + int32_t Max_height= 0; }screen; struct Built { diff --git a/sources/main.cpp b/sources/main.cpp index 8f54279b5..ee70a90ac 100644 --- a/sources/main.cpp +++ b/sources/main.cpp @@ -241,6 +241,11 @@ QGuiApplication::setHighDpiScaleFactorRoundingPolicy(QetSettings::hdpiScaleFacto QObject::connect(&app, &SingleApplication::receivedMessage, &qetapp, &QETApp::receiveMessage); + // Pre-initialise on the main (GUI) thread: the constructor calls + // qApp->screens() which is not thread-safe in Qt5 — calling instance() + // here guarantees the singleton is fully built before the worker runs. + MachineInfo::instance(); + QtConcurrent::run([=]() { // for debugging diff --git a/sources/qetdiagrameditor.h b/sources/qetdiagrameditor.h index d5139ed5a..5a26b5f06 100644 --- a/sources/qetdiagrameditor.h +++ b/sources/qetdiagrameditor.h @@ -80,6 +80,11 @@ class QETDiagramEditor : public QETMainWindow protected: bool event(QEvent *) override; private: + // Declared first so it is initialised before any member whose + // constructor may dispatch a Qt event calling event() (e.g. the + // QActionGroup members below trigger QObject::setParent events). + bool m_first_show = true; + QETDiagramEditor(const QETDiagramEditor &); void setUpElementsPanel (); void setUpElementsCollectionWidget(); @@ -253,7 +258,6 @@ class QETDiagramEditor : public QETMainWindow QUndoGroup undo_group; AutoNumberingDockWidget *m_autonumbering_dock; int activeSubWindowIndex; - bool m_first_show = true; SearchAndReplaceWidget m_search_and_replace_widget; }; #endif