Fix for some memory leaks issue #657

This commit is contained in:
ffsup2 2011-06-07 20:12:01 +02:00
parent c109330c53
commit fbb9cff8ee
9 changed files with 31 additions and 18 deletions

View File

@ -513,6 +513,7 @@ template<class T> void bilateral (T** src, T** dst, int W, int H, int sigmar, do
delete [] rhist;
for (int i=0; i<H; i++)
delete [] buff_final[i];
delete [] buff_final;
}
#endif

View File

@ -119,9 +119,9 @@ ImageIO::~ImageIO () {
if (embProfile)
cmsCloseProfile(embProfile);
delete loadedProfileData;
delete [] loadedProfileData;
delete exifRoot;
delete profileData;
delete [] profileData;
}
void png_read_data(png_struct_def *png_ptr, unsigned char *data, size_t length);
@ -278,9 +278,11 @@ int ImageIO::loadJPEGFromMemory (const char* buffer, int bufsize)
//jpeg_memory_src (&cinfo,buffer,bufsize);
jpeg_read_header(&cinfo, TRUE);
unsigned int proflen;
delete loadedProfileData;
loadedProfileData = NULL;
unsigned int proflen;
if( loadedProfileData ){
delete [] loadedProfileData;
loadedProfileData = NULL;
}
bool hasprofile = read_icc_profile (&cinfo, (JOCTET**)&loadedProfileData, (unsigned int*)&loadedProfileLength);
if (hasprofile)
embProfile = cmsOpenProfileFromMem (loadedProfileData, loadedProfileLength);
@ -434,8 +436,10 @@ int ImageIO::loadTIFF (Glib::ustring fname) {
}
char* profdata;
delete loadedProfileData;
loadedProfileData = NULL;
if( loadedProfileData ){
delete [] loadedProfileData;
loadedProfileData = NULL;
}
if (TIFFGetField(in, TIFFTAG_ICCPROFILE, &loadedProfileLength, &profdata)) {
embProfile = cmsOpenProfileFromMem (profdata, loadedProfileLength);
loadedProfileData = new char [loadedProfileLength];

View File

@ -97,9 +97,9 @@ CurveEditor::CurveEditor (Glib::ustring text, CurveEditorGroup* ceGroup, CurveEd
subGroup = ceSubGroup;
if (group && text.size())
curveType = Gtk::manage (new PopUpToggleButton(text + ":"));
curveType = new PopUpToggleButton(text + ":");
else
curveType = Gtk::manage (new PopUpToggleButton());
curveType = new PopUpToggleButton();
curveType->set_tooltip_text(M("CURVEEDITOR_TYPE"));
// TODO: Does this signal have to be blocked when on curve type change ?
@ -108,7 +108,7 @@ CurveEditor::CurveEditor (Glib::ustring text, CurveEditorGroup* ceGroup, CurveEd
}
CurveEditor::~CurveEditor () {
delete curveType;
delete [] histogram;
}

View File

@ -48,7 +48,7 @@ FileCatalog::FileCatalog (CoarsePanel* cp, ToolBar* tb) : selectedDirectoryId(1)
inTabMode=false;
// construct and initialize thumbnail browsers
fileBrowser = new FileBrowser();
fileBrowser = Gtk::manage( new FileBrowser() );
fileBrowser->setFileBrowserListener (this);
fileBrowser->setArrangement (ThumbBrowserBase::TB_Vertical);
fileBrowser->show ();

View File

@ -36,9 +36,9 @@ FilePanel::FilePanel () : parent(NULL) {
dirpaned = Gtk::manage ( new Gtk::HPaned () );
dirpaned->set_position (options.dirBrowserWidth);
dirBrowser = new DirBrowser ();
placesBrowser = new PlacesBrowser ();
recentBrowser = new RecentBrowser ();
dirBrowser = Gtk::manage ( new DirBrowser () );
placesBrowser = Gtk::manage ( new PlacesBrowser () );
recentBrowser = Gtk::manage ( new RecentBrowser () );
placespaned = Gtk::manage ( new Gtk::VPaned () );
placespaned->set_size_request(50,100);
@ -54,7 +54,7 @@ FilePanel::FilePanel () : parent(NULL) {
dirpaned->pack1 (*placespaned, false, true);
tpc = new BatchToolPanelCoordinator (this);
fileCatalog = new FileCatalog (tpc->coarse, tpc->getToolBar());
fileCatalog = Gtk::manage ( new FileCatalog (tpc->coarse, tpc->getToolBar()) );
ribbonPane = Gtk::manage ( new Gtk::Paned() );
ribbonPane->add(*fileCatalog);
ribbonPane->set_size_request(50,150);
@ -72,7 +72,7 @@ FilePanel::FilePanel () : parent(NULL) {
rightNotebook = Gtk::manage ( new Gtk::Notebook () );
//Gtk::VBox* taggingBox = Gtk::manage ( new Gtk::VBox () );
history = new History (false);
history = Gtk::manage ( new History (false) );
tpc->addPParamsChangeListener (history);
history->setProfileChangeListener (tpc);

View File

@ -61,6 +61,7 @@ PopUpCommon::~PopUpCommon () {
}
if (menu) delete menu;
if (buttonImage) delete buttonImage;
delete buttonGroup;
}
PopUpCommon::type_signal_changed PopUpCommon::signal_changed() {

View File

@ -34,7 +34,7 @@ public:
Gtk::HBox* buttonGroup; // this is the widget to be packed
PopUpCommon (Gtk::Button* button, const Glib::ustring& label = "");
~PopUpCommon ();
virtual ~PopUpCommon ();
bool addEntry (Glib::ustring imagePath, Glib::ustring label);
bool setSelected (int entryNum);
int getSelected () { return selected; }

View File

@ -28,7 +28,7 @@ SaveFormatPanel::SaveFormatPanel () : listener (NULL) {
pngcompr = new Adjuster (M("SAVEDLG_PNGCOMPR"), 0, 6, 1, 6);
pngcompr->setAdjusterListener (this);
pngcompr->show ();
tiffuncompressed = Gtk::manage (new Gtk::CheckButton (M("SAVEDLG_TIFFUNCOMPRESSED")));
tiffuncompressed = new Gtk::CheckButton (M("SAVEDLG_TIFFUNCOMPRESSED"));
tiffuncompressed->signal_toggled().connect( sigc::mem_fun(*this,&SaveFormatPanel::formatChanged));
tiffuncompressed->show();
@ -64,6 +64,12 @@ SaveFormatPanel::SaveFormatPanel () : listener (NULL) {
fstr[3] = "png";
fstr[4] = "png";
}
SaveFormatPanel::~SaveFormatPanel ()
{
delete jpegqual;
delete pngcompr;
delete tiffuncompressed;
}
void SaveFormatPanel::init (SaveFormat &sf) {

View File

@ -47,6 +47,7 @@ class SaveFormatPanel : public Gtk::VBox, public AdjusterListener {
public:
SaveFormatPanel ();
~SaveFormatPanel ();
void setListener (FormatChangeListener* l) { listener = l; }
void init (SaveFormat& sf);