[Kstars-devel] branches/kstars/summer/kstars/kstars
Prakash Mohan
prak902000 at gmail.com
Tue Jul 14 17:47:20 CEST 2009
SVN commit 996646 by prakash:
Making the Comast::Log class a single instance class.
CCMAIL: kstars-devel at kde.org
M +8 -0 comast/log.cpp
M +2 -0 comast/log.h
M +4 -4 tools/observinglist.cpp
--- branches/kstars/summer/kstars/kstars/comast/log.cpp #996645:996646
@@ -22,6 +22,14 @@
#include "skycomponents/constellationboundary.h"
#include "kstarsdatetime.h"
+Comast::Log *pinstance = NULL;
+
+Comast::Log* Comast::Log::Instance() {
+ if( !pinstance )
+ pinstance = new Comast::Log;
+ return pinstance;
+}
+
void Comast::Log::writeBegin() {
writer = new QXmlStreamWriter(&output);
writer->setAutoFormatting( true );
--- branches/kstars/summer/kstars/kstars/comast/log.h #996645:996646
@@ -38,6 +38,7 @@
class Comast::Log {
public:
+ static Comast::Log* Instance();
QString writeLog( bool native = true );
void writeBegin();
void writeGeoDate();
@@ -70,6 +71,7 @@
void readPosition();
void readGeoDate();
private:
+ Log() {}
QList<SkyObject *> m_targetList;
QList<Comast::Observer *> m_observerList;
QList<Comast::Eyepiece *> m_eyepieceList;
--- branches/kstars/summer/kstars/kstars/tools/observinglist.cpp #996645:996646
@@ -853,8 +853,8 @@
QTextStream istream( &f );
QString input;
input = istream.readAll();
- Comast::Log logObject;
- logObject.readBegin( input );
+ Comast::Log *logObject = Comast::Log::Instance();
+ logObject->readBegin( input );
//Update the location and user set times from file
slotUpdate();
//Newly-opened list should not trigger isModified flag
@@ -956,8 +956,8 @@
return;
}
QTextStream ostream( &f );
- Comast::Log log;
- ostream<< log.writeLog( nativeSave );
+ Comast::Log *logObject = Comast::Log::Instance();
+ ostream<< logObject->writeLog( nativeSave );
f.close();
isModified = false;//We've saved the session, so reset the modified flag.
}
More information about the Kstars-devel
mailing list