From 3db4bb7f3bd4245b6aff0cf446cdd12e12e1a3e2 Mon Sep 17 00:00:00 2001 From: K D Hedger Date: Thu, 21 Dec 2023 14:56:17 +0000 Subject: [PATCH] fixed some mem leaks --- LFSDock/ChangeLog | 1 + LFSDock/LFSDock/src/calendar.cpp | 1 + LFSDock/LFSDock/src/calendar.h | 4 ++- LFSDock/LFSDock/src/desktopSwitcher.cpp | 1 - LFSDock/LFSDock/src/launchers.cpp | 8 +++--- LFSDock/LFSDock/src/main.cpp | 26 ++++++++++++++++--- LFSDock/LFSDock/src/taskBar.cpp | 3 ++- LFSToolKit/ChangeLog | 1 + LFSToolKit/LFSToolKit/lfstk/LFSTKLib.cpp | 17 +++++++----- .../LFSToolKit/lfstk/LFSTKMultiLineEdit.cpp | 4 +-- makeall | 2 +- 11 files changed, 48 insertions(+), 20 deletions(-) diff --git a/LFSDock/ChangeLog b/LFSDock/ChangeLog index 41217a7..97b862a 100644 --- a/LFSDock/ChangeLog +++ b/LFSDock/ChangeLog @@ -1,4 +1,5 @@ 0.2.0 +Fixed mem leak. Added date reminder file to calendar (~/.config/LFS/calendardates). Added calendar widget. Fixed updating window names in task lists. diff --git a/LFSDock/LFSDock/src/calendar.cpp b/LFSDock/LFSDock/src/calendar.cpp index cf4cb5f..14cb1ce 100644 --- a/LFSDock/LFSDock/src/calendar.cpp +++ b/LFSDock/LFSDock/src/calendar.cpp @@ -227,6 +227,7 @@ int addCalendar(int x,int y,int grav) editbox->LFSTK_moveGadget(0,0); editbox->LFSTK_resizeWindow(txtwid,std::floor(txthite)); + editbox->LFSTK_setStyle(BEVELNONE); editbox->LFSTK_setEditable(false); editbox->LFSTK_setIgnores(false,false); editbox->LFSTK_addHighLights(dx,dy,dl,datesHilite[0]); diff --git a/LFSDock/LFSDock/src/calendar.h b/LFSDock/LFSDock/src/calendar.h index 0f3f597..6a4d7a3 100644 --- a/LFSDock/LFSDock/src/calendar.h +++ b/LFSDock/LFSDock/src/calendar.h @@ -36,9 +36,11 @@ struct datesStruct }; extern LFSTK_windowClass *calWindow; -extern bool calWindowVisible; extern LFSTK_toggleButtonClass *calendarButton; +extern LFSTK_multiLineEditClass *editbox; +extern bool calWindowVisible; extern bool calendarIsUp; +extern std::vector datesData; int addCalendar(int x,int y,int grav); diff --git a/LFSDock/LFSDock/src/desktopSwitcher.cpp b/LFSDock/LFSDock/src/desktopSwitcher.cpp index 33624e2..04befde 100644 --- a/LFSDock/LFSDock/src/desktopSwitcher.cpp +++ b/LFSDock/LFSDock/src/desktopSwitcher.cpp @@ -97,7 +97,6 @@ bool desktopSelect(void *object,void* userdata) int addDesktopSwitcer(int x,int y,int grav) { char *icon=NULL; - windowInitStruct *win=new windowInitStruct;; listLabelStruct ls; std::string label; propertyStruct props; diff --git a/LFSDock/LFSDock/src/launchers.cpp b/LFSDock/LFSDock/src/launchers.cpp index 70b2025..b30a2c4 100644 --- a/LFSDock/LFSDock/src/launchers.cpp +++ b/LFSDock/LFSDock/src/launchers.cpp @@ -239,6 +239,7 @@ int addLaunchers(int x,int y,int grav) entry.name=NULL; entry.exec=NULL; entry.inTerm=false; +freeAndNull(&icon); addALAuncher(findlaunchers->data.at(l).path.c_str(),&entry); @@ -266,10 +267,11 @@ int addLaunchers(int x,int y,int grav) else bc->LFSTK_setImageFromPath(DATADIR "/pixmaps/command.png",LEFT,true); +freeAndNull(&icon); +//freeAndNull(&entry.icon); setGadgetDetails(bc); - - if(icon!=NULL) - freeAndNull(&icon); + //if(icon!=NULL) + // freeAndNull(&icon); launchersArray.push_back(lds); g_free(entry.name); g_free(entry.exec); diff --git a/LFSDock/LFSDock/src/main.cpp b/LFSDock/LFSDock/src/main.cpp index 8081e20..6f475f1 100644 --- a/LFSDock/LFSDock/src/main.cpp +++ b/LFSDock/LFSDock/src/main.cpp @@ -314,20 +314,38 @@ int main(int argc,char **argv) int retval=apc->LFSTK_runApp(); + +/* +extern LFSTK_windowClass *calWindow; +extern bool calWindowVisible; +extern LFSTK_toggleButtonClass *calendarButton; +extern bool calendarIsUp; +*/ + //delete editbox; + //delete calWindow; + //delete calendarButton; + calendarIsUp=false; + freeAndNull(&iconL); freeAndNull(&iconM); freeAndNull(&iconH); - clockButton=NULL; - switchButton=NULL; - gotLaunchers=false; - useTaskBar=false; holdtasks.clear(); filltasks.clear(); tasks.clear(); launchersArray.clear(); + datesData.clear(); + delete gFind; delete findlaunchers; delete apc; + clockButton=NULL; + switchButton=NULL; + calendarButton=NULL; + editbox=NULL; + calWindow=NULL; + gotLaunchers=false; + useTaskBar=false; + } cairo_debug_reset_static_data(); g_key_file_free(kf); diff --git a/LFSDock/LFSDock/src/taskBar.cpp b/LFSDock/LFSDock/src/taskBar.cpp index cea1f2b..10fae04 100644 --- a/LFSDock/LFSDock/src/taskBar.cpp +++ b/LFSDock/LFSDock/src/taskBar.cpp @@ -263,7 +263,8 @@ skiplabel: for(int j=0;jglobalLib->LFSTK_findThemedIcon(desktopTheme,filltasks.at(j).taskClass[0].c_str(),""); if(icon==NULL) icon=dockWindow->globalLib->LFSTK_findThemedIcon(desktopTheme,filltasks.at(j).taskClass[1].c_str(),""); diff --git a/LFSToolKit/ChangeLog b/LFSToolKit/ChangeLog index 7194505..75a41c7 100644 --- a/LFSToolKit/ChangeLog +++ b/LFSToolKit/ChangeLog @@ -1,4 +1,5 @@ 0.6.0 +Fixed memleaks. Fixed bevel in multi line class. Fixed extra highlighting in multi box. Fixed minor memory leak in window/application class. diff --git a/LFSToolKit/LFSToolKit/lfstk/LFSTKLib.cpp b/LFSToolKit/LFSToolKit/lfstk/LFSTKLib.cpp index 1b22e66..f0b026f 100644 --- a/LFSToolKit/LFSToolKit/lfstk/LFSTKLib.cpp +++ b/LFSToolKit/LFSToolKit/lfstk/LFSTKLib.cpp @@ -561,8 +561,8 @@ char* LFSTK_lib::LFSTK_findThemedIcon(const char *theme,const char *icon,const c char *iconpath=NULL; const char *iconthemes[3]; const char *iconfolders[GLOBALPIXMAPSEND]; - bool maskdot=false; - char *holdicon=NULL; + bool maskdot=false; + char *holdicon=NULL; if(icon[0]=='/') return(strdup(icon)); @@ -596,9 +596,9 @@ char* LFSTK_lib::LFSTK_findThemedIcon(const char *theme,const char *icon,const c if((iconpath!=NULL) && (strlen(iconpath)>1)) goto breakReturn; - if(iconpath!=NULL) - freeAndNull(&iconpath); - iconpath=NULL; + //if(iconpath!=NULL) + freeAndNull(&iconpath); + //iconpath=NULL; } } @@ -617,6 +617,7 @@ char* LFSTK_lib::LFSTK_findThemedIcon(const char *theme,const char *icon,const c breakReturn: freeAndNull(&holdicon); + //freeAndNull(&iconpath); return(iconpath); } @@ -806,9 +807,11 @@ char* LFSTK_lib::LFSTK_oneLiner(const char* fmt,...) } pclose(fp); freeAndNull(&subbuffer); - return(strdup(buffer)); + //return(strdup(buffer)); + return(buffer); } freeAndNull(&subbuffer); + freeAndNull(&buffer); return(NULL); } @@ -1223,6 +1226,8 @@ void LFSTK_lib::LFSTK_getFileInfo(const char* path,fileInformation* info) file=g_file_new_for_path(path); file_info=g_file_query_info(file,"standard::*",G_FILE_QUERY_INFO_NONE,NULL,&error); th=g_file_info_get_content_type(file_info); + g_clear_object(&file); + g_clear_object(&file_info); if(th.length()!=0) info->mimeType=th; else diff --git a/LFSToolKit/LFSToolKit/lfstk/LFSTKMultiLineEdit.cpp b/LFSToolKit/LFSToolKit/lfstk/LFSTKMultiLineEdit.cpp index ef9f0ce..71aa879 100644 --- a/LFSToolKit/LFSToolKit/lfstk/LFSTKMultiLineEdit.cpp +++ b/LFSToolKit/LFSToolKit/lfstk/LFSTKMultiLineEdit.cpp @@ -41,6 +41,7 @@ LFSTK_multiLineEditClass::~LFSTK_multiLineEditClass() } this->lines.clear(); } + this->highLights.clear(); } LFSTK_multiLineEditClass::LFSTK_multiLineEditClass() @@ -226,9 +227,6 @@ void LFSTK_multiLineEditClass::drawText(void) cairo_save(this->cr); cairo_reset_clip(this->cr); cairo_set_source_rgba(this->cr,this->newGadgetBGColours.at(NORMALCOLOUR).RGBAColour.r,this->newGadgetBGColours.at(NORMALCOLOUR).RGBAColour.g,this->newGadgetBGColours.at(NORMALCOLOUR).RGBAColour.b,this->newGadgetBGColours.at(NORMALCOLOUR).RGBAColour.a); - -//cairo_rectangle(this->cr,0,0,this->gadgetGeom.w-1,this->gadgetGeom.h-1); -// cairo_fill(this->cr); cairo_paint(this->cr); cairo_restore(this->cr); diff --git a/makeall b/makeall index 4b8bb14..202bba8 100755 --- a/makeall +++ b/makeall @@ -119,7 +119,7 @@ makelocal () #runCommand "./autogen.sh --prefix=/usr --libdir=/usr/lib${LIBDIRSUFFIX}" : else - CFLAGS="-Wfatal-errors -I${CWD}/LFSToolKit/LFSToolKit/lfstk/ -L${CWD}/LFSToolKit/LFSToolKit/app/.libs" + CFLAGS="-O0 -g -Wfatal-errors -I${CWD}/LFSToolKit/LFSToolKit/lfstk/ -L${CWD}/LFSToolKit/LFSToolKit/app/.libs" CXXFLAGS="$CFLAGS" export CFLAGS CXXFLAGS runCommand "./autogen.sh --prefix=/usr"