on xenial help sign in
simplify
ad4743eMichael Zanetti
tests/mocks/GSettings/fake_gsettings.cpp+7−11
@@ -25,24 +25,20 @@ struct GSettingsQmlPrivate {
25 GSettingsSchemaQml *schema;
25 GSettingsSchemaQml *schema;
26};
26};
27
27
28−bool GSettingsControllerQml::instance_exists;
29−GSettingsControllerQml* GSettingsControllerQml::_controllerInstance;
28+GSettingsControllerQml* GSettingsControllerQml::s_controllerInstance = 0;
30
29
31GSettingsControllerQml::GSettingsControllerQml() {
30GSettingsControllerQml::GSettingsControllerQml() {
32}
31}
33
32
34GSettingsControllerQml::~GSettingsControllerQml() {
33GSettingsControllerQml::~GSettingsControllerQml() {
35− instance_exists = false;
34+ s_controllerInstance = 0;
36}
35}
37
36
38−GSettingsControllerQml* GSettingsControllerQml::getInstance() {
37+GSettingsControllerQml* GSettingsControllerQml::instance() {
39− if(!instance_exists) {
38+ if(!s_controllerInstance) {
40− _controllerInstance = new GSettingsControllerQml();
39+ s_controllerInstance = new GSettingsControllerQml();
41− instance_exists = true;
42− return _controllerInstance;
43− } else {
44− return _controllerInstance;
45 }
40 }
41+ return s_controllerInstance;
46}
42}
47
43
48GSettingsSchemaQml::GSettingsSchemaQml(QObject *parent): QObject(parent) {
44GSettingsSchemaQml::GSettingsSchemaQml(QObject *parent): QObject(parent) {
@@ -80,7 +76,7 @@ void GSettingsSchemaQml::setPath(const QByteArray &path) {
80}
76}
81
77
82GSettingsQml::GSettingsQml(QObject *parent): QObject(parent) {
78GSettingsQml::GSettingsQml(QObject *parent): QObject(parent) {
83− GSettingsControllerQml::getInstance();
79+ GSettingsControllerQml::instance();
84 priv = new GSettingsQmlPrivate;
80 priv = new GSettingsQmlPrivate;
85 priv->schema = new GSettingsSchemaQml(this);
81 priv->schema = new GSettingsSchemaQml(this);
86}
82}
tests/mocks/GSettings/fake_gsettings.h+2−6
@@ -25,17 +25,13 @@ class GSettingsControllerQml: public QObject
25 Q_OBJECT
25 Q_OBJECT
26
26
27public:
27public:
28− static GSettingsControllerQml* getInstance();
28+ static GSettingsControllerQml* instance();
29 ~GSettingsControllerQml();
29 ~GSettingsControllerQml();
30
30
31private:
31private:
32 GSettingsControllerQml();
32 GSettingsControllerQml();
33− GSettingsControllerQml(const GSettingsControllerQml&);
34− GSettingsControllerQml& operator=(const GSettingsControllerQml&);
35
33
36− static bool instance_exists;
37−
38− static GSettingsControllerQml* _controllerInstance;
34+ static GSettingsControllerQml* s_controllerInstance;
39};
35};
40
36
41class GSettingsSchemaQml: public QObject
37class GSettingsSchemaQml: public QObject
tests/mocks/GSettings/plugin.cpp+1−1
@@ -21,7 +21,7 @@
21
21
22static QObject* controllerProvider(QQmlEngine* /* engine */, QJSEngine* /* scriptEngine */)
22static QObject* controllerProvider(QQmlEngine* /* engine */, QJSEngine* /* scriptEngine */)
23{
23{
24− return GSettingsControllerQml::getInstance();
24+ return GSettingsControllerQml::instance();
25}
25}
26
26
27void FakeGSettingsQmlPlugin::registerTypes(const char *uri)
27void FakeGSettingsQmlPlugin::registerTypes(const char *uri)