X-Git-Url: https://vaikene.ee/gitweb/pswgen11.html?a=blobdiff_plain;ds=inline;f=src%2Flibs%2FCommon%2Fprop.cpp;h=b76c3c5417d54ae4942d16912d491602c76ea689;hb=de270ece1b764b19968e14420f538321f1c06b15;hp=f6cfec6395b2813131aa91103d071dcd33cde47b;hpb=0c61450fcffcb36a6e23ca5b083c26543d956084;p=evaf
diff --git a/src/libs/Common/prop.cpp b/src/libs/Common/prop.cpp
index f6cfec6..b76c3c5 100644
--- a/src/libs/Common/prop.cpp
+++ b/src/libs/Common/prop.cpp
@@ -3,7 +3,7 @@
* @brief Implementation of the iProp interface
* @author Enar Vaikene
*
- * Copyright (c) 2011 Enar Vaikene
+ * Copyright (c) 2011-2019 Enar Vaikene
*
* This file is part of the eVaf C++ cross-platform application development framework.
*
@@ -31,10 +31,18 @@
using namespace eVaf::Common;
+namespace
+{
+ static Internal::Prop * singleton = nullptr;
+}
+
iProp * iProp::instance()
{
- static Internal::Prop singleton;
- return singleton._interface();
+ if (nullptr == singleton)
+ {
+ singleton = new Internal::Prop;
+ }
+ return singleton->_interface();
}
@@ -42,19 +50,30 @@ iProp * iProp::instance()
using namespace eVaf::Common::Internal;
+void Prop::destroyInstance()
+{
+ if (nullptr != singleton)
+ {
+ delete singleton;
+ singleton = nullptr;
+ }
+}
+
Prop::Prop()
: iProp()
- , mPersistentProps(0)
{
setObjectName(QString("%1.iProp").arg(VER_MODULE_NAME_STR));
// Register the iProp interface
iRegistry::instance()->registerInterface("iProp", this);
+
+ EVAF_INFO("%s-Prop created", VER_MODULE_NAME_STR);
}
Prop::~Prop()
{
done();
+ EVAF_INFO("%s-Prop destroyed", VER_MODULE_NAME_STR);
}
iProp * Prop::_interface() const
@@ -80,7 +99,7 @@ bool Prop::init()
isProp = true;
}
else if (isProp && xml.name() == "property") {
-#ifdef Q_OS_LINUX
+#if defined(Q_OS_LINUX) || defined(Q_OS_MACOS)
if (isTrue(xml.attributes().value("windowsonly").toString()))
continue;
#endif
@@ -116,9 +135,10 @@ bool Prop::init()
}
// Initialize persistent properties
- if (mPersistentProps)
- delete mPersistentProps;
- mPersistentProps = new QSettings(QString("%1/.%2.dat").arg(iApp::instance()->dataRootDir()).arg(iApp::instance()->name()), QSettings::IniFormat);
+ mPersistentProps.reset(new QSettings(QString("%1/.%2.dat")
+ .arg(iApp::instance()->dataRootDir())
+ .arg(iApp::instance()->name()),
+ QSettings::IniFormat));
QStringList keys = mPersistentProps->allKeys();
for (int i = 0; i < keys.size(); ++i) {
QString key = keys.at(i);
@@ -130,10 +150,7 @@ bool Prop::init()
void Prop::done()
{
- if (mPersistentProps) {
- delete mPersistentProps;
- mPersistentProps = 0;
- }
+ mPersistentProps.reset();
}
QVariant Prop::getValue(QString const & name, QVariant const & defaultValue) const