* @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.
*
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();
}
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
+iProp * Prop::_interface() const
{
return evafQueryInterface<iProp>("iProp");
}
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
}
// 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);
void Prop::done()
{
- if (mPersistentProps) {
- delete mPersistentProps;
- mPersistentProps = 0;
- }
+ mPersistentProps.reset();
}
QVariant Prop::getValue(QString const & name, QVariant const & defaultValue) const