diff options
author | Hugo Lima <hugo.lima@openbossa.org> | 2009-09-18 15:02:04 -0300 |
---|---|---|
committer | Hugo Lima <hugo.lima@openbossa.org> | 2009-09-18 15:02:04 -0300 |
commit | 38283f8ae3a479dbc213ff16c8b727094028bb9a (patch) | |
tree | 48dbd447ab9e2f7d6702bcc78c0a386c30357cc7 /typesystem.cpp | |
parent | be5fb84cf7a20d7fe446ef8fdb3b03914fca8526 (diff) |
- Turn ctors of TypeDatabase private (It's a singleton!)
- Makes possible to reset the TypeDatabase, this is usefull in unit tests
when you need to make all unit tests independent of each other.
Diffstat (limited to 'typesystem.cpp')
-rw-r--r-- | typesystem.cpp | 9 |
1 files changed, 7 insertions, 2 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; } |