From 9f43b528a974d2987f17aeb898fe2bf5b0a58060 Mon Sep 17 00:00:00 2001 From: sln Date: Mon, 5 Dec 2011 11:01:28 +0000 Subject: [PATCH] Remove temporary files from destructor --- src/SUIT/SUIT_Session.cxx | 16 ++++++++++++++-- src/SUIT/SUIT_Session.h | 1 + 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/SUIT/SUIT_Session.cxx b/src/SUIT/SUIT_Session.cxx index b85562b85..7ebb712f6 100755 --- a/src/SUIT/SUIT_Session.cxx +++ b/src/SUIT/SUIT_Session.cxx @@ -75,6 +75,9 @@ SUIT_Session::~SUIT_Session() fclose( myBFile ); if ( !myBFolder.isEmpty() ) Qtx::rmDir( myBFolder ); + + // remove all unused temporary folders + removeTmpFiles(); } /*! \retval return mySession */ @@ -669,13 +672,23 @@ void SUIT_Session::restoreBackup() } // remove all unused temporary folders + removeTmpFiles(); +} + +/*! + Remove useless unused files +*/ +void SUIT_Session::removeTmpFiles() +{ QString savePref = getSavePrefix(); + QDir tmpDir( QDir::tempPath() ); - filt.clear(); + QStringList filt; filt.append( savePref + "*" ); tmpDir.setNameFilters( filt ); QStringList tmpFolders = tmpDir.entryList( QDir::Dirs ); + QStringList::iterator it; for ( it = tmpFolders.begin(); it != tmpFolders.end(); ++it ) { // iterate through tmp folders @@ -688,4 +701,3 @@ void SUIT_Session::restoreBackup() } } } - diff --git a/src/SUIT/SUIT_Session.h b/src/SUIT/SUIT_Session.h index bc9928593..f062a6dba 100755 --- a/src/SUIT/SUIT_Session.h +++ b/src/SUIT/SUIT_Session.h @@ -98,6 +98,7 @@ private slots: private: void createBackupTimer(); void restoreBackup(); + void removeTmpFiles(); private: typedef QList AppList; -- 2.39.2