Fixes small memory leaks

This commit is contained in:
heckflosse
2017-06-07 23:40:03 +02:00
parent a64421fb91
commit a24e8475f6
2 changed files with 14 additions and 2 deletions

View File

@@ -39,7 +39,7 @@ void ProfilePanel::cleanup ()
delete partialProfileDlg; delete partialProfileDlg;
} }
ProfilePanel::ProfilePanel () : storedPProfile(nullptr), lastFilename(""), imagePath(""), lastSavedPSE(nullptr) ProfilePanel::ProfilePanel () : storedPProfile(nullptr), lastFilename(""), imagePath(""), lastSavedPSE(nullptr), customPSE(nullptr)
{ {
tpc = nullptr; tpc = nullptr;
@@ -129,6 +129,7 @@ ProfilePanel::~ProfilePanel ()
delete profileFillModeOnImage; delete profileFillModeOnImage;
delete profileFillModeOffImage; delete profileFillModeOffImage;
delete lastSavedPSE; delete lastSavedPSE;
delete customPSE;
} }
bool ProfilePanel::isCustomSelected() bool ProfilePanel::isCustomSelected()
@@ -165,13 +166,23 @@ Gtk::TreeIter ProfilePanel::getLastSavedRow()
Gtk::TreeIter ProfilePanel::addCustomRow() Gtk::TreeIter ProfilePanel::addCustomRow()
{ {
const ProfileStoreEntry *customPSE = new ProfileStoreEntry(Glib::ustring ("(" + M("PROFILEPANEL_PCUSTOM") + ")"), PSET_FILE, 0, 0); if(customPSE) {
delete customPSE;
customPSE = nullptr;
}
customPSE = new ProfileStoreEntry(Glib::ustring ("(" + M("PROFILEPANEL_PCUSTOM") + ")"), PSET_FILE, 0, 0);
Gtk::TreeIter newEntry = profiles->addRow(customPSE); Gtk::TreeIter newEntry = profiles->addRow(customPSE);
return newEntry; return newEntry;
} }
Gtk::TreeIter ProfilePanel::addLastSavedRow() Gtk::TreeIter ProfilePanel::addLastSavedRow()
{ {
if(lastSavedPSE) {
delete lastSavedPSE;
lastSavedPSE = nullptr;
}
lastSavedPSE = new ProfileStoreEntry(Glib::ustring ("(" + M("PROFILEPANEL_PLASTSAVED") + ")"), PSET_FILE, 0, 0); lastSavedPSE = new ProfileStoreEntry(Glib::ustring ("(" + M("PROFILEPANEL_PLASTSAVED") + ")"), PSET_FILE, 0, 0);
Gtk::TreeIter newEntry = profiles->addRow(lastSavedPSE); Gtk::TreeIter newEntry = profiles->addRow(lastSavedPSE);
return newEntry; return newEntry;

View File

@@ -43,6 +43,7 @@ private:
Gtk::ToggleButton* fillMode; Gtk::ToggleButton* fillMode;
Gtk::TreeIter currRow; Gtk::TreeIter currRow;
ProfileStoreEntry *lastSavedPSE; ProfileStoreEntry *lastSavedPSE;
ProfileStoreEntry *customPSE;
void profileFillModeToggled (); void profileFillModeToggled ();
bool isCustomSelected (); bool isCustomSelected ();