From: sln Date: Tue, 27 Nov 2012 13:17:25 +0000 (+0000) Subject: 1) Crash on Linux study closing X-Git-Tag: CTH_1_8_0~4 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=42374a3cd3c85696cd5cf10a76df7cfab4c4e56c;p=modules%2Fgui.git 1) Crash on Linux study closing 2) Close .fcntl file before removing to delete study folder correctly --- diff --git a/src/SUIT/SUIT_Session.cxx b/src/SUIT/SUIT_Session.cxx index 9ab60b1ab..215416c87 100755 --- a/src/SUIT/SUIT_Session.cxx +++ b/src/SUIT/SUIT_Session.cxx @@ -83,6 +83,12 @@ SUIT_Session::~SUIT_Session() // remove backup if ( myBFile ) fclose( myBFile ); + +#ifndef WIN32 + if ( myBFileFcntl ) + fclose( myBFileFcntl ); +#endif + if ( !myBFolder.isEmpty() ) Qtx::rmDir( myBFolder ); @@ -576,14 +582,20 @@ int SUIT_Session::lockFcntl( QString theLF ) if ( theLF.isEmpty() ) aFD = myBFileFcntl; else + { aFD = fopen( theLF.toLatin1().constData(), "w" ); + if ( !aFD ) + return -1; + } struct flock fLock; fLock.l_type = F_WRLCK; fLock.l_whence = SEEK_SET; fLock.l_len = 0; fLock.l_start = 0; - return fcntl( fileno( aFD ), F_SETLK, &fLock ); + + int ret = fcntl( fileno( aFD ), F_SETLK, &fLock ); + return ret; } #endif @@ -787,7 +799,13 @@ void SUIT_Session::removeTmpFiles( const bool withBackup ) if ( !QFileInfo( blocName ).exists() || !locked ) { // unused non-removed folder +#ifdef WIN32 Qtx::rmDir( currF ); +#else + // use the system call Qtx::rmDir() may not work on Linux + QString cmd = QString( "rm -rf " ) + currF.toLatin1().constData(); + system( cmd.toLatin1().constData() ); +#endif } } }