diff options
-rw-r--r-- | typesystem.cpp | 9 | ||||
-rw-r--r-- | typesystem.h | 11 |
2 files changed, 16 insertions, 4 deletions
diff --git a/typesystem.cpp b/typesystem.cpp index 4b32b965f..ae5c3a1c8 100644 --- a/typesystem.cpp +++ b/typesystem.cpp @@ -1591,9 +1591,14 @@ bool Handler::startElement(const QString &, const QString &n, return true; } -TypeDatabase *TypeDatabase::instance() +TypeDatabase *TypeDatabase::instance(bool newInstance) { - static TypeDatabase *db = new TypeDatabase(); + static TypeDatabase *db = 0; + if (!db || newInstance) { + if (db) + delete db; + db = new TypeDatabase; + } return db; } diff --git a/typesystem.h b/typesystem.h index 65dd28a01..945461a2d 100644 --- a/typesystem.h +++ b/typesystem.h @@ -1718,10 +1718,17 @@ struct TypeRejection class TypeDatabase { -public: TypeDatabase(); + TypeDatabase(const TypeDatabase&); + TypeDatabase& operator=(const TypeDatabase&); +public: - static TypeDatabase *instance(); + /** + * Return the type system instance. + * \param newInstance This parameter is usefull just for unit testing, because singletons causes + * too many side effects on unit testing. + */ + static TypeDatabase *instance(bool newInstance = false); QStringList requiredTargetImports() { |