diff options
| author | Thomas Vanbesien <tvanbesi@proton.me> | 2026-02-19 18:00:52 +0100 |
|---|---|---|
| committer | Thomas Vanbesien <tvanbesi@proton.me> | 2026-02-19 18:00:52 +0100 |
| commit | e73fe498e86dbb20d74f8d6ca13b541642676b82 (patch) | |
| tree | 572593fd880d10ae23544986116847271ee49f99 /src/BobinkClient.cpp | |
| parent | 50c62c35463b62a3a7acebf9ebe22d44f1c6dca2 (diff) | |
| download | BobinkQtOpcUa-e73fe498e86dbb20d74f8d6ca13b541642676b82.tar.gz BobinkQtOpcUa-e73fe498e86dbb20d74f8d6ca13b541642676b82.zip | |
Rename QML singleton to Bobink and simplify singleton lifecycle
Replace QML_ELEMENT with QML_NAMED_ELEMENT(Bobink) so QML references
use `Bobink` instead of `BobinkClient`. Remove instance()/create()
factory in favor of inline s_instance set in the constructor. Import
BobinkPlugin statically in demo, link demo to BobinkQtOpcUaplugin,
and make library link dependencies PUBLIC. Add .qtcreator to gitignore.
Diffstat (limited to 'src/BobinkClient.cpp')
| -rw-r--r-- | src/BobinkClient.cpp | 28 |
1 files changed, 3 insertions, 25 deletions
diff --git a/src/BobinkClient.cpp b/src/BobinkClient.cpp index f8303a3..01f9912 100644 --- a/src/BobinkClient.cpp +++ b/src/BobinkClient.cpp @@ -11,8 +11,6 @@ using namespace Qt::Literals::StringLiterals; -BobinkClient *BobinkClient::s_instance = nullptr; - static QString defaultPkiDir () { @@ -36,35 +34,15 @@ BobinkClient::BobinkClient (QObject *parent) : QObject (parent), m_provider (new QOpcUaProvider (this)), m_pkiDir (defaultPkiDir ()) { + // Singleton pattern: construct only once + Q_ASSERT(!s_instance); ensurePkiDirs (m_pkiDir); setupClient (); autoDetectPki (); applyPki (); connect (&m_discoveryTimer, &QTimer::timeout, this, &BobinkClient::doDiscovery); -} - -BobinkClient::~BobinkClient () -{ - if (s_instance == this) - s_instance = nullptr; -} - -BobinkClient * -BobinkClient::instance () -{ - return s_instance; -} - -BobinkClient * -BobinkClient::create (QQmlEngine *, QJSEngine *) -{ - if (!s_instance) - { - s_instance = new BobinkClient; - QJSEngine::setObjectOwnership (s_instance, QJSEngine::CppOwnership); - } - return s_instance; + s_instance = this; } void |
