[kstars] kstars: Fixing some issues with memory as reported by Valgrind, need to check more. Please double check.
Jasem Mutlaq
mutlaqja at ikarustech.com
Sun Sep 4 10:57:09 UTC 2016
Git commit 0acf553c250d3498be85bed26746369aacaf684b by Jasem Mutlaq.
Committed on 04/09/2016 at 10:56.
Pushed by mutlaqja into branch 'master'.
Fixing some issues with memory as reported by Valgrind, need to check more. Please double check.
CCMAIL:kstars-devel at kde.org
M +4 -1 kstars/auxiliary/binfilehelper.cpp
M +19 -15 kstars/auxiliary/fov.cpp
M +3 -1 kstars/auxiliary/fov.h
M +2 -4 kstars/auxiliary/ksuserdb.cpp
M +1 -1 kstars/auxiliary/ksuserdb.h
M +18 -9 kstars/ekos/align.cpp
M +2 -0 kstars/ekos/align.h
M +41 -1 kstars/ekos/align.ui
M +14 -8 kstars/ekos/ekosmanager.cpp
M +1 -1 kstars/fitsviewer/fitsview.cpp
M +1 -0 kstars/indi/drivermanager.cpp
M +1 -0 kstars/indi/indiccd.cpp
M +1 -0 kstars/indi/indilistener.cpp
M +4 -0 kstars/kstars.kcfg
M +4 -1 kstars/tools/observinglist.cpp
http://commits.kde.org/kstars/0acf553c250d3498be85bed26746369aacaf684b
diff --git a/kstars/auxiliary/binfilehelper.cpp b/kstars/auxiliary/binfilehelper.cpp
index 0a7b977..2476a82 100644
--- a/kstars/auxiliary/binfilehelper.cpp
+++ b/kstars/auxiliary/binfilehelper.cpp
@@ -110,9 +110,12 @@ enum BinFileHelper::Errors BinFileHelper::__readHeader() {
if( byteswap ) nfields = bswap_16( nfields );
fields.clear();
for(i = 0; i < nfields; ++i) {
+ // FIXME: Valgrind shows 176 bytes lost here in 11 blocks. Why? Investigate
de = new dataElement;
- if(!fread(de, sizeof(dataElement), 1, fileHandle)) {
+ if(!fread(de, sizeof(dataElement), 1, fileHandle))
+ {
delete de;
+ qDeleteAll(fields);
return ERR_FD_TRUNC;
}
if( byteswap ) de->scale = bswap_32( de->scale );
diff --git a/kstars/auxiliary/fov.cpp b/kstars/auxiliary/fov.cpp
index db9e35d..4fb7ee0 100644
--- a/kstars/auxiliary/fov.cpp
+++ b/kstars/auxiliary/fov.cpp
@@ -32,6 +32,7 @@
#include <QStandardPaths>
#include "kspaths.h"
+QList<FOV*> FOV::m_FOVs;
FOV::Shape FOV::intToShape(int s)
{
@@ -208,20 +209,21 @@ void FOV::writeFOVs(const QList<FOV*> fovs)
f.close();
}
-QList<FOV*> FOV::readFOVs()
+const QList<FOV*> & FOV::readFOVs()
{
QFile f;
- QList<FOV*> fovs;
+ qDeleteAll(m_FOVs);
+ m_FOVs.clear();
f.setFileName( KSPaths::writableLocation(QStandardPaths::GenericDataLocation) + "fov.dat" ) ;
if( !f.exists() ) {
- fovs = defaults();
- writeFOVs(fovs);
- return fovs;
+ m_FOVs = defaults();
+ writeFOVs(m_FOVs);
+ return m_FOVs;
}
- if( f.open(QIODevice::ReadOnly) ) {
- fovs.clear();
+ if( f.open(QIODevice::ReadOnly) )
+ {
QTextStream istream(&f);
while( !istream.atEnd() ) {
QStringList fields = istream.readLine().split(':');
@@ -234,39 +236,41 @@ QList<FOV*> FOV::readFOVs()
name = fields[0];
sizeX = fields[1].toFloat(&ok);
if( !ok ) {
- return QList<FOV*>();
+ return m_FOVs;
}
sizeY = fields[2].toFloat(&ok);
if( !ok ) {
- return QList<FOV*>();
+ return m_FOVs;
}
xoffset = fields[3].toFloat(&ok);
if( !ok ) {
- return QList<FOV*>();
+ return m_FOVs;
}
yoffset = fields[4].toFloat(&ok);
if( !ok ) {
- return QList<FOV*>();
+ return m_FOVs;
}
rot = fields[5].toFloat(&ok);
if( !ok ) {
- return QList<FOV*>();
+ return m_FOVs;
}
shape = intToShape( fields[6].toInt(&ok) );
if( !ok ) {
- return QList<FOV*>();
+ return m_FOVs;
}
color = fields[7];
} else {
continue;
}
- fovs.append( new FOV(name, sizeX, sizeY, xoffset, yoffset, rot, shape, color) );
+
+ //FIXME: This still shows lost blocks in Valgrind despite the fact memory is always cleared?
+ m_FOVs.append( new FOV(name, sizeX, sizeY, xoffset, yoffset, rot, shape, color) );
}
}
- return fovs;
+ return m_FOVs;
}
SkyPoint FOV::center() const
{
diff --git a/kstars/auxiliary/fov.h b/kstars/auxiliary/fov.h
index bc8fd5a..4c30bd9 100644
--- a/kstars/auxiliary/fov.h
+++ b/kstars/auxiliary/fov.h
@@ -86,7 +86,7 @@ public:
/** @short Write list of FOVs to "fov.dat" */
static void writeFOVs(const QList<FOV*> fovs);
/** @short Read list of FOVs from "fov.dat" */
- static QList<FOV*>readFOVs();
+ static const QList<FOV*> & readFOVs();
SkyPoint center() const;
void setCenter(const SkyPoint ¢er);
@@ -109,6 +109,8 @@ private:
QImage m_image;
bool m_imageDisplay;
+ static QList<FOV*> m_FOVs;
+
};
#endif
diff --git a/kstars/auxiliary/ksuserdb.cpp b/kstars/auxiliary/ksuserdb.cpp
index 17c9764..384dee9 100644
--- a/kstars/auxiliary/ksuserdb.cpp
+++ b/kstars/auxiliary/ksuserdb.cpp
@@ -1211,10 +1211,8 @@ void KSUserDB::SaveProfile(ProfileInfo *pi)
}
-QList<ProfileInfo *> KSUserDB::GetAllProfiles()
+void KSUserDB::GetAllProfiles(QList<ProfileInfo *> &profiles)
{
- QList<ProfileInfo *> profiles;
-
userdb_.open();
QSqlTableModel profile(0, userdb_);
profile.setTable("profile");
@@ -1227,6 +1225,7 @@ QList<ProfileInfo *> KSUserDB::GetAllProfiles()
int id = record.value("id").toInt();
QString name = record.value("name").toString();
+ // FIXME: This still shows 562 bytes lost in Valgrind, why? Investigate
ProfileInfo *pi = new ProfileInfo(id, name);
// Add host and port
@@ -1249,7 +1248,6 @@ QList<ProfileInfo *> KSUserDB::GetAllProfiles()
profile.clear();
userdb_.close();
- return profiles;
}
void KSUserDB::GetProfileDrivers(ProfileInfo* pi)
diff --git a/kstars/auxiliary/ksuserdb.h b/kstars/auxiliary/ksuserdb.h
index 0127fd8..674146f 100644
--- a/kstars/auxiliary/ksuserdb.h
+++ b/kstars/auxiliary/ksuserdb.h
@@ -73,7 +73,7 @@ class KSUserDB {
* @return QMap with the keys as profile names and values are profile ids.
*/
//QMap<int, QStringList> GetAllProfiles();
- QList<ProfileInfo *> GetAllProfiles();
+ void GetAllProfiles(QList<ProfileInfo *> &profiles);
/************************************************************************
******************************* Observers ******************************
diff --git a/kstars/ekos/align.cpp b/kstars/ekos/align.cpp
index cb77926..9367858 100644
--- a/kstars/ekos/align.cpp
+++ b/kstars/ekos/align.cpp
@@ -81,6 +81,7 @@ Align::Align()
retries=0;
targetDiff=1e6;
solverIterations=0;
+ fov_x=fov_y=0;
parser = NULL;
solverFOV = new FOV();
@@ -172,7 +173,7 @@ Align::Align()
connect(parser, SIGNAL(solverFailed()), this, SLOT(solverFailed()));
}
- kcfg_solverOptions->setText(Options::solverOptions());
+ solverOptions->setText(Options::solverOptions());
// Which telescope info to use for FOV calculations
kcfg_solverOTA->setChecked(Options::solverOTA());
@@ -189,6 +190,9 @@ Align::Align()
connect(exposureIN, SIGNAL(valueChanged(double)), this, SLOT(invalidateDarkFrame()));
connect(CCDCaptureCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(invalidateDarkFrame()));
connect(alignDarkFrameCheck, SIGNAL(toggled(bool)), this, SLOT(invalidateDarkFrame()));
+
+ delaySpin->setValue(Options::settlingTime());
+ connect(delaySpin, SIGNAL(editingFinished()), this, SLOT(saveSettleTime()));
}
Align::~Align()
@@ -487,14 +491,14 @@ void Align::generateArgs()
getFormattedCoords(ra, dec, ra_dms, dec_dms);
- if (kcfg_solverOptions->text().isEmpty())
+ if (solverOptions->text().isEmpty())
{
solver_args << "--no-verify" << "--no-plots" << "--no-fits2fits" << "--resort"
<< "--downsample" << "2" << "-O" << "-L" << fov_low << "-H" << fov_high << "-u" << "aw";
}
else
{
- solver_args = kcfg_solverOptions->text().split(" ");
+ solver_args = solverOptions->text().split(" ");
int fov_low_index = solver_args.indexOf("-L");
if (fov_low_index != -1)
solver_args.replace(fov_low_index+1, fov_low);
@@ -554,7 +558,7 @@ void Align::generateArgs()
}
- kcfg_solverOptions->setText(solver_args.join(" "));
+ solverOptions->setText(solver_args.join(" "));
}
void Align::checkLineEdits()
@@ -809,7 +813,7 @@ void Align::startSolving(const QString &filename, bool isGenerated)
Options::setSolverUpdateCoords(kcfg_solverUpdateCoords->isChecked());
Options::setSolverType(solverTypeGroup->checkedId());
Options::setSolverPreview(kcfg_solverPreview->isChecked());
- Options::setSolverOptions(kcfg_solverOptions->text());
+ Options::setSolverOptions(solverOptions->text());
Options::setSolverOTA(kcfg_solverOTA->isChecked());
Options::setWCSAlign(wcsCheck->isChecked());
Options::setSolverOverlay(kcfg_solverOverlay->isChecked());
@@ -831,7 +835,7 @@ void Align::startSolving(const QString &filename, bool isGenerated)
solverTimer.start();
if (isGenerated)
- solverArgs = kcfg_solverOptions->text().split(" ");
+ solverArgs = solverOptions->text().split(" ");
else if (filename.endsWith("fits") || filename.endsWith("fit"))
{
solverArgs = getSolverOptionsFromFITS(filename);
@@ -1063,7 +1067,7 @@ void Align::processTelescopeNumber(INumberVectorProperty *coord)
if (loadSlewMode)
{
loadSlewMode = false;
- QTimer::singleShot(1500, this, SLOT(captureAndSolve()));
+ QTimer::singleShot(delaySpin->value(), this, SLOT(captureAndSolve()));
return;
}
else if (m_slewToTargetSelected)
@@ -1086,7 +1090,7 @@ void Align::processTelescopeNumber(INumberVectorProperty *coord)
}
appendLogText(i18n("Target accuracy is not met, running solver again..."));
- QTimer::singleShot(1500, this, SLOT(captureAndSolve()));
+ QTimer::singleShot(delaySpin->value(), this, SLOT(captureAndSolve()));
return;
}
}
@@ -1709,7 +1713,7 @@ void Align::setBinning(int binX, int binY)
void Align::setSolverArguments(const QString & value)
{
- kcfg_solverOptions->setText(value);
+ solverOptions->setText(value);
}
void Align::setSolverSearchOptions(double ra, double dec, double radius)
@@ -1992,6 +1996,11 @@ void Align::invalidateDarkFrame()
}
}
+void Align::saveSettleTime()
+{
+ Options::setSettlingTime(delaySpin->value());
+}
+
}
diff --git a/kstars/ekos/align.h b/kstars/ekos/align.h
index f0d0327..496db45 100644
--- a/kstars/ekos/align.h
+++ b/kstars/ekos/align.h
@@ -311,6 +311,8 @@ private slots:
/* We need to take a dark frame when CCD, Frame size, or exposure time changes */
void invalidateDarkFrame();
+ void saveSettleTime();
+
signals:
void newLog();
void solverComplete(bool);
diff --git a/kstars/ekos/align.ui b/kstars/ekos/align.ui
index b39cc3d..04bcda0 100644
--- a/kstars/ekos/align.ui
+++ b/kstars/ekos/align.ui
@@ -438,7 +438,7 @@
</widget>
</item>
<item>
- <widget class="QLineEdit" name="kcfg_solverOptions">
+ <widget class="QLineEdit" name="solverOptions">
<property name="statusTip">
<string>Additional options to be the solver</string>
</property>
@@ -787,6 +787,46 @@
</widget>
</item>
<item>
+ <widget class="Line" name="line_3">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="label_22">
+ <property name="toolTip">
+ <string>After telescope complete slewing, wait until it settles before capturing the next image.</string>
+ </property>
+ <property name="text">
+ <string>Settle</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QSpinBox" name="delaySpin">
+ <property name="toolTip">
+ <string>After telescope completes slewing, delay capture of nex</string>
+ </property>
+ <property name="maximum">
+ <number>5000</number>
+ </property>
+ <property name="singleStep">
+ <number>100</number>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="label_23">
+ <property name="toolTip">
+ <string>Milliseconds</string>
+ </property>
+ <property name="text">
+ <string>ms</string>
+ </property>
+ </widget>
+ </item>
+ <item>
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
diff --git a/kstars/ekos/ekosmanager.cpp b/kstars/ekos/ekosmanager.cpp
index bf8c1fb..1daeb79 100644
--- a/kstars/ekos/ekosmanager.cpp
+++ b/kstars/ekos/ekosmanager.cpp
@@ -61,11 +61,13 @@ EkosManager::EkosManager(QWidget *parent) : QDialog(parent)
useST4 =false;
isStarted = false;
remoteManagerStart=false;
+ localMode = true;
indiConnectionStatus = EKOS_STATUS_IDLE;
ekosStartingStatus = EKOS_STATUS_IDLE;
- profileModel = NULL;
+ profileModel = new QStandardItemModel(0, 4);
+ profileModel->setHorizontalHeaderLabels(QStringList() << "id" << "name" << "host" << "port");
captureProcess = NULL;
focusProcess = NULL;
@@ -163,6 +165,13 @@ EkosManager::~EkosManager()
delete mountProcess;
delete schedulerProcess;
delete dustCapProcess;
+ delete profileModel;
+
+ delete previewPixmap;
+ delete focusStarPixmap;
+ delete focusProfilePixmap;
+ delete guideProfilePixmap;
+ delete guideStarPixmap;
}
void EkosManager::closeEvent(QCloseEvent * /*event*/)
@@ -199,14 +208,11 @@ void EkosManager::resizeEvent(QResizeEvent *)
void EkosManager::loadProfiles()
{
- profiles = KStarsData::Instance()->userdb()->GetAllProfiles();
-
- if (profileModel)
- profileModel->clear();
- else
- profileModel = new QStandardItemModel(0, 4);
+ qDeleteAll(profiles);
+ profiles.clear();
+ KStarsData::Instance()->userdb()->GetAllProfiles(profiles);
- profileModel->setHorizontalHeaderLabels(QStringList() << "id" << "name" << "host" << "port");
+ profileModel->clear();
foreach(ProfileInfo *pi, profiles)
{
diff --git a/kstars/fitsviewer/fitsview.cpp b/kstars/fitsviewer/fitsview.cpp
index e07e259..4ee30a4 100644
--- a/kstars/fitsviewer/fitsview.cpp
+++ b/kstars/fitsviewer/fitsview.cpp
@@ -523,7 +523,7 @@ int FITSView::rescale(FITSZoom type)
}
if (display_buffer != image_buffer)
- delete (display_buffer);
+ delete [] display_buffer;
switch (type)
{
diff --git a/kstars/indi/drivermanager.cpp b/kstars/indi/drivermanager.cpp
index 9bce7f7..a7c32b3 100644
--- a/kstars/indi/drivermanager.cpp
+++ b/kstars/indi/drivermanager.cpp
@@ -139,6 +139,7 @@ DriverManager::DriverManager(QWidget *parent)
DriverManager::~DriverManager()
{
clearServers();
+ qDeleteAll(driversList);
}
void DriverManager::processDeviceStatus(DriverInfo *dv)
diff --git a/kstars/indi/indiccd.cpp b/kstars/indi/indiccd.cpp
index 294d65e..f062d9f 100644
--- a/kstars/indi/indiccd.cpp
+++ b/kstars/indi/indiccd.cpp
@@ -1183,6 +1183,7 @@ void CCD::processBLOB(IBLOB* bp)
if (targetChip->getCaptureMode() == FITS_NORMAL && targetChip->isBatchMode() == true)
KStars::Instance()->statusBar()->showMessage( i18n("%1 file saved to %2", QString(fmt).toUpper(), filename ), 0);
+ // FIXME: Why is this leaking memory in Valgrind??!
KNotification::event( QLatin1String( "FITSReceived" ) , i18n("FITS file is received"));
/*if (targetChip->showFITS() == false && targetChip->getCaptureMode() == FITS_NORMAL)
diff --git a/kstars/indi/indilistener.cpp b/kstars/indi/indilistener.cpp
index bccfbcb..fd1d204 100644
--- a/kstars/indi/indilistener.cpp
+++ b/kstars/indi/indilistener.cpp
@@ -62,6 +62,7 @@ INDIListener::INDIListener(QObject *parent) : QObject(parent)
INDIListener::~INDIListener()
{
qDeleteAll(devices);
+ qDeleteAll(st4Devices);
}
bool INDIListener::isStandardProperty(const QString &name)
diff --git a/kstars/kstars.kcfg b/kstars/kstars.kcfg
index b51b9e4..2aeca5c 100644
--- a/kstars/kstars.kcfg
+++ b/kstars/kstars.kcfg
@@ -1553,6 +1553,10 @@
<label>Take a dark frame and subtract it before running astrometry operation.</label>
<default>false</default>
</entry>
+ <entry name="SettlingTime" type="UInt">
+ <label>Time to wait in milliseconds after telescope slewing is complete before starting the next capture.</label>
+ <default>1500</default>
+ </entry>
</group>
<group name="Guide">
<entry name="DefaultGuideCCD" type="String">
diff --git a/kstars/tools/observinglist.cpp b/kstars/tools/observinglist.cpp
index ce4448f..9b57b26 100644
--- a/kstars/tools/observinglist.cpp
+++ b/kstars/tools/observinglist.cpp
@@ -140,7 +140,7 @@ ObservingList::ObservingList()
ui->WishListView->horizontalHeader()->setStretchLastSection( true );
ui->WishListView->horizontalHeader()->setSectionResizeMode( QHeaderView::Interactive );
- m_SessionSortModel = new SessionSortFilterProxyModel;
+ m_SessionSortModel = new SessionSortFilterProxyModel();
m_SessionSortModel->setSourceModel( m_SessionModel );
m_SessionSortModel->setDynamicSortFilter( true );
ui->SessionView->setModel( m_SessionSortModel );
@@ -237,6 +237,9 @@ ObservingList::ObservingList()
ObservingList::~ObservingList()
{
delete ksal;
+ delete m_SessionModel;
+ delete m_WishListModel;
+ delete m_SessionSortModel;
}
//SLOTS
More information about the Kstars-devel
mailing list