[Kstars-devel] [kstars] kstars: Ensure that we never create two KStarsData instances.
Akarsh Simha
akarshsimha at gmail.com
Sun Oct 30 09:03:44 UTC 2011
Git commit a0b6731bc25f9f16c8e8befae15b4b32b37daf4a by Akarsh Simha.
Committed on 30/10/2011 at 10:03.
Pushed by asimha into branch 'master'.
Ensure that we never create two KStarsData instances.
CCMAIL: kstars-devel at kde.org
M +9 -0 kstars/kstarsdata.cpp
http://commits.kde.org/kstars/a0b6731bc25f9f16c8e8befae15b4b32b37daf4a
diff --git a/kstars/kstarsdata.cpp b/kstars/kstarsdata.cpp
index e10a8a8..6165f1b 100644
--- a/kstars/kstarsdata.cpp
+++ b/kstars/kstarsdata.cpp
@@ -98,6 +98,15 @@ KStarsData* KStarsData::pinstance = 0;
KStarsData* KStarsData::Create()
{
+ // This method should never be called twice within a run, since a
+ // lot of the code assumes that KStarsData, once created, is never
+ // destroyed. They maintain local copies of KStarsData::Instance()
+ // for efficiency (maybe this should change, but it is not
+ // required to delete and reinstantiate KStarsData). Thus, when we
+ // call this method, pinstance MUST be zero, i.e. this must be the
+ // first (and last) time we are calling it. -- asimha
+ Q_ASSERT( !pinstance );
+
delete pinstance;
pinstance = new KStarsData();
return pinstance;
More information about the Kstars-devel
mailing list