mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-02-13 16:18:42 +00:00
the settings code was leaking and it was copy/pasted in a few files.
created a method to find QSettings (settings.h) and stopped it from leaking. The leak looked like this... ==7800== at 0x4C2726C: operator new(unsigned long) (vg_replace_malloc.c:230) ==7800== by 0x64FD232: (within /usr/lib/libQtCore.so.4.5.0) ==7800== by 0x64FDB62: QSettings::QSettings(QString const&, QString const&, Q Object*) (in /usr/lib/libQtCore.so.4.5.0) ==7800== by 0x4738E5: PfPvPlot::setData(RideItem*) (PfPvPlot.cpp:361)
This commit is contained in:
@@ -94,18 +94,12 @@ MainWindow::parseRideFileName(const QString &name, QString *notesFileName, QDate
|
||||
}
|
||||
|
||||
MainWindow::MainWindow(const QDir &home) :
|
||||
home(home), settings(NULL),
|
||||
home(home),
|
||||
zones(NULL), currentNotesChanged(false),
|
||||
ride(NULL)
|
||||
{
|
||||
|
||||
QDir tempHome = QDir();
|
||||
if(!tempHome.exists("Library/GoldenCheetah"))
|
||||
settings = new QSettings(GC_SETTINGS_CO, GC_SETTINGS_APP);
|
||||
else
|
||||
settings = new QSettings(tempHome.absolutePath()+"/gc", QSettings::IniFormat);
|
||||
|
||||
|
||||
settings = GetApplicationSettings();
|
||||
|
||||
QVariant unit = settings->value(GC_UNIT);
|
||||
useMetricUnits = (unit.toString() == "Metric");
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@ class MainWindow : public QMainWindow
|
||||
void setHistBinWidthText();
|
||||
void setHistTextValidator();
|
||||
|
||||
QSettings *settings;
|
||||
boost::shared_ptr<QSettings> settings;
|
||||
|
||||
RideCalendar *calendar;
|
||||
QSplitter *splitter;
|
||||
|
||||
@@ -100,16 +100,8 @@ ManualRideDialog::ManualRideDialog(MainWindow *mainWindow,
|
||||
|
||||
// how to estimate BikeScore:
|
||||
QLabel *BSEstLabel;
|
||||
QSettings *settings;
|
||||
|
||||
//First check to see if the Library folder exists where the executable is (for USB sticks)
|
||||
|
||||
QDir tempHome = QDir();
|
||||
if(!tempHome.exists("Library/GoldenCheetah"))
|
||||
settings = new QSettings(GC_SETTINGS_CO, GC_SETTINGS_APP);
|
||||
else
|
||||
settings = new QSettings(home.absolutePath()+"/gc", QSettings::IniFormat);
|
||||
|
||||
boost::shared_ptr<QSettings> settings = GetApplicationSettings();
|
||||
|
||||
QVariant BSmode = settings->value(GC_BIKESCOREMODE);
|
||||
|
||||
|
||||
|
||||
@@ -27,13 +27,8 @@ ConfigurationPage::ConfigurationPage()
|
||||
unitCombo = new QComboBox();
|
||||
unitCombo->addItem(tr("Metric"));
|
||||
unitCombo->addItem(tr("English"));
|
||||
//First check to see if the Library folder exists where the executable is (for USB sticks)
|
||||
QDir home = QDir();
|
||||
QSettings *settings;
|
||||
if(!home.exists("Library/GoldenCheetah"))
|
||||
settings = new QSettings(GC_SETTINGS_CO, GC_SETTINGS_APP);
|
||||
else
|
||||
settings = new QSettings(home.absolutePath()+"/gc", QSettings::IniFormat);
|
||||
|
||||
boost::shared_ptr<QSettings> settings = GetApplicationSettings();
|
||||
|
||||
QVariant unit = settings->value(GC_UNIT);
|
||||
|
||||
|
||||
@@ -162,13 +162,7 @@ PfPvPlot::PfPvPlot()
|
||||
curve->setRenderHint(QwtPlotItem::RenderAntialiased);
|
||||
curve->attach(this);
|
||||
|
||||
//First check to see if the Library folder exists where the executable is (for USB sticks)
|
||||
QDir home = QDir();
|
||||
QSettings *settings;
|
||||
if(!home.exists("Library/GoldenCheetah"))
|
||||
settings = new QSettings(GC_SETTINGS_CO, GC_SETTINGS_APP);
|
||||
else
|
||||
settings = new QSettings(home.absolutePath()+"/gc", QSettings::IniFormat);
|
||||
boost::shared_ptr<QSettings> settings = GetApplicationSettings();
|
||||
|
||||
cl_ = settings->value(GC_CRANKLENGTH).toDouble() / 1000.0;
|
||||
|
||||
@@ -360,13 +354,8 @@ PfPvPlot::setData(RideItem *_rideItem)
|
||||
}
|
||||
|
||||
replot();
|
||||
//First check to see if the Library folder exists where the executable is (for USB sticks)
|
||||
QDir home = QDir();
|
||||
QSettings *settings;
|
||||
if(!home.exists("Library/GoldenCheetah"))
|
||||
settings = new QSettings(GC_SETTINGS_CO, GC_SETTINGS_APP);
|
||||
else
|
||||
settings = new QSettings(home.absolutePath()+"/gc", QSettings::IniFormat);
|
||||
|
||||
boost::shared_ptr<QSettings> settings = GetApplicationSettings();
|
||||
setCL(settings->value(GC_CRANKLENGTH).toDouble() / 1000.0);
|
||||
}
|
||||
|
||||
|
||||
@@ -205,13 +205,8 @@ PowerHist::PowerHist():
|
||||
lny(false)
|
||||
{
|
||||
|
||||
QDir home = QDir();
|
||||
QSettings *settings;
|
||||
if(!home.exists("Library/GoldenCheetah"))
|
||||
settings = new QSettings(GC_SETTINGS_CO, GC_SETTINGS_APP);
|
||||
else
|
||||
settings = new QSettings(home.absolutePath()+"/gc", QSettings::IniFormat);
|
||||
|
||||
boost::shared_ptr<QSettings> settings = GetApplicationSettings();
|
||||
|
||||
unit = settings->value(GC_UNIT);
|
||||
|
||||
useMetricUnits = (unit.toString() == "Metric");
|
||||
|
||||
@@ -192,13 +192,7 @@ QStringList RideFileFactory::listRideFiles(const QDir &dir) const
|
||||
filters << ("*." + i.key());
|
||||
}
|
||||
// This will read the user preferences and change the file list order as necessary:
|
||||
//First check to see if the Library folder exists where the executable is (for USB sticks)
|
||||
QDir home = QDir();
|
||||
QSettings *settings;
|
||||
if(!home.exists("Library/GoldenCheetah"))
|
||||
settings = new QSettings(GC_SETTINGS_CO, GC_SETTINGS_APP);
|
||||
else
|
||||
settings = new QSettings(home.absolutePath()+"/gc", QSettings::IniFormat);
|
||||
boost::shared_ptr<QSettings> settings = GetApplicationSettings();;
|
||||
|
||||
QVariant isAscending = settings->value(GC_ALLRIDES_ASCENDING,Qt::Checked);
|
||||
if(isAscending.toInt()>0){
|
||||
|
||||
@@ -92,13 +92,8 @@ static void summarize(QString &intervals,
|
||||
intervals = intervals.arg(watts_avg, 0, 'f', 0);
|
||||
intervals = intervals.arg(hr_avg, 0, 'f', 0);
|
||||
intervals = intervals.arg(cad_avg, 0, 'f', 0);
|
||||
//First check to see if the Library folder exists where the executable is (for USB sticks)
|
||||
QDir home = QDir();
|
||||
QSettings *settings;
|
||||
if(!home.exists("Library/GoldenCheetah"))
|
||||
settings = new QSettings(GC_SETTINGS_CO, GC_SETTINGS_APP);
|
||||
else
|
||||
settings = new QSettings(home.absolutePath()+"/gc", QSettings::IniFormat);
|
||||
|
||||
boost::shared_ptr<QSettings> settings = GetApplicationSettings();
|
||||
|
||||
QVariant unit = settings->value(GC_UNIT);
|
||||
if(unit.toString() == "Metric")
|
||||
|
||||
@@ -37,5 +37,21 @@
|
||||
#define GC_BIKESCOREDAYS "bikeScoreDays"
|
||||
#define GC_BIKESCOREMODE "bikeScoreMode"
|
||||
|
||||
#include <QSettings>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
inline boost::shared_ptr<QSettings> GetApplicationSettings()
|
||||
{
|
||||
boost::shared_ptr<QSettings> settings;
|
||||
QDir home = QDir();
|
||||
//First check to see if the Library folder exists where the executable is (for USB sticks)
|
||||
if(!home.exists("Library/GoldenCheetah"))
|
||||
settings = boost::shared_ptr<QSettings>(new QSettings(GC_SETTINGS_CO, GC_SETTINGS_APP));
|
||||
else
|
||||
settings = boost::shared_ptr<QSettings>(new QSettings(home.absolutePath()+"/gc", QSettings::IniFormat));
|
||||
|
||||
return settings;
|
||||
}
|
||||
|
||||
#endif // _GC_Settings_h
|
||||
|
||||
|
||||
Reference in New Issue
Block a user