From 4b12d7678d8d589f956e0b0ea21ee21b365bca32 Mon Sep 17 00:00:00 2001 From: sln Date: Thu, 30 Aug 2012 08:12:36 +0000 Subject: [PATCH] Nullify file handler after fclose(); exception on Linux --- src/LightApp/LightApp_Driver.cxx | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/LightApp/LightApp_Driver.cxx b/src/LightApp/LightApp_Driver.cxx index 15bf14521..51c9c647f 100644 --- a/src/LightApp/LightApp_Driver.cxx +++ b/src/LightApp/LightApp_Driver.cxx @@ -245,7 +245,10 @@ void LightApp_Driver::SetListOfFiles( const char* theModuleName, const ListOfFil myMap[aName] = theListOfFiles; if ( myBloc ) + { fclose( myBloc ); + myBloc = 0; + } QString fName = Qtx::addSlash( theListOfFiles.front().c_str() ) + "used_by_salome"; myBloc = fopen( fName.toLatin1().constData(), "w" ); @@ -254,7 +257,10 @@ void LightApp_Driver::SetListOfFiles( const char* theModuleName, const ListOfFil fName += ".fcntl"; if ( myBlocFcntl ) + { fclose( myBlocFcntl ); + myBlocFcntl = 0; + } myBlocFcntl = fopen( fName.toLatin1().constData(), "w" ); lockFcntl( QString() ); #endif @@ -347,6 +353,7 @@ void LightApp_Driver::RemoveTemporaryFiles( const char* theModuleName, const boo if ( myBloc ) { fclose( myBloc ); + myBloc = 0; QString fName = Qtx::addSlash( aFiles.front().c_str() ) + "used_by_salome"; QFile::remove( fName ); } @@ -354,6 +361,7 @@ void LightApp_Driver::RemoveTemporaryFiles( const char* theModuleName, const boo if ( myBlocFcntl ) { fclose( myBlocFcntl ); + myBlocFcntl = 0; QString fName = Qtx::addSlash( aFiles.front().c_str() ) + "used_by_salome.fcntl"; QFile::remove( fName ); } @@ -446,14 +454,20 @@ std::string LightApp_Driver::GetTmpDir() myTmpDir = aTmpDir.ToCString(); if ( myBloc ) + { fclose( myBloc ); + myBloc = 0; + } QString blocName = Qtx::addSlash(tmpDir) + "used_by_salome"; myBloc = fopen( blocName.toLatin1().constData(), "w" ); #ifndef WIN32 blocName += ".fcntl"; if ( myBlocFcntl ) + { fclose( myBlocFcntl ); + myBlocFcntl = 0; + } myBlocFcntl = fopen( blocName.toLatin1().constData(), "w" ); lockFcntl( QString() ); #endif -- 2.39.2