From: sln Date: Wed, 22 Aug 2012 11:53:54 +0000 (+0000) Subject: Support of 64-bit platforms X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=b26cd45117a899c517b895189df782ec601130e7;p=modules%2Fgui.git Support of 64-bit platforms --- diff --git a/src/LightApp/LightApp_Application.cxx b/src/LightApp/LightApp_Application.cxx index dce1076b2..02c07a4ee 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -1846,7 +1846,9 @@ void LightApp_Application::createPreferences( LightApp_Preferences* pref ) pref->addPreference( tr( "PREF_MULTI_FILE" ), studyGroup, LightApp_Preferences::Bool, "Study", "multi_file" ); pref->addPreference( tr( "PREF_ASCII_FILE" ), studyGroup, LightApp_Preferences::Bool, "Study", "ascii_file" ); pref->addPreference( tr( "PREF_STORE_POS" ), studyGroup, LightApp_Preferences::Bool, "Study", "store_positions" ); - pref->addPreference( tr( "PREF_BACKUP" ), studyGroup, LightApp_Preferences::DblSpin, "Study", "backup_studies" ); + + if ( !SUIT_Session::session()->getBackupFolder().isEmpty() ) + pref->addPreference( tr( "PREF_BACKUP" ), studyGroup, LightApp_Preferences::DblSpin, "Study", "backup_studies" ); int extgroup = pref->addPreference( tr( "PREF_GROUP_EXT_BROWSER" ), genTab ); QString platform; diff --git a/src/LightApp/LightApp_Driver.cxx b/src/LightApp/LightApp_Driver.cxx index eb42e2d33..15bf14521 100644 --- a/src/LightApp/LightApp_Driver.cxx +++ b/src/LightApp/LightApp_Driver.cxx @@ -509,8 +509,8 @@ bool LightApp_Driver::PutFilesToFirstStream( const std::string& theModuleName, u TCollection_AsciiString aTmpDir(const_cast(aFiles[0].c_str())); int aNbFiles = 0; - myFileNameSizes = new size_t[aLength]; - myFileSizes = new size_t[aLength]; + myFileNameSizes = new t_size[aLength]; + myFileSizes = new t_size[aLength]; //Determine the required size of the buffer TCollection_AsciiString aFileName; @@ -544,7 +544,7 @@ bool LightApp_Driver::PutFilesToFirstStream( const std::string& theModuleName, u mySizeToBeWritten += 4; //4 bytes for a number of the files that will be written to the stream; - size_t aCurrSize = mySizeToBeWritten <= GetMaxBuffSize() ? mySizeToBeWritten : GetMaxBuffSize(); + t_size aCurrSize = mySizeToBeWritten <= GetMaxBuffSize() ? mySizeToBeWritten : GetMaxBuffSize(); theBuffer = new unsigned char[ aCurrSize ]; myCurrBuff = theBuffer; @@ -609,7 +609,7 @@ bool LightApp_Driver::PutFilesToFirstStream( const std::string& theModuleName, u { myCurrIFile->seekg(0, ios::beg); int aPos = myCurrIFile->tellg(); - size_t aSizeToRead = GetMaxBuffSize() - myCurrPos; + t_size aSizeToRead = GetMaxBuffSize() - myCurrPos; if ( aSizeToRead > myFileSizes[myCurrFileIndex] - myCurrIFile->tellg() ) aSizeToRead = myFileSizes[myCurrFileIndex] - myCurrIFile->tellg(); myCurrIFile->read((char *)(theBuffer + myCurrPos), aSizeToRead ); @@ -666,7 +666,7 @@ bool LightApp_Driver::PutFilesToNextStream( const std::string& theModuleName, un TCollection_AsciiString aTmpDir(const_cast(aFiles[0].c_str())); - size_t aCurrSize = mySizeToBeWritten <= GetMaxBuffSize() ? mySizeToBeWritten : GetMaxBuffSize(); + t_size aCurrSize = mySizeToBeWritten <= GetMaxBuffSize() ? mySizeToBeWritten : GetMaxBuffSize(); for ( ; myCurrFileIndex < aLength; myCurrFileIndex++ ) { @@ -713,7 +713,7 @@ bool LightApp_Driver::PutFilesToNextStream( const std::string& theModuleName, un if ( aCurrSize < GetMaxBuffSize() ) { //myCurrIFile->seekg(0, ios::beg); - size_t aSizeToRead = myFileSizes[myCurrFileIndex] - myCurrIFile->tellg(); + t_size aSizeToRead = myFileSizes[myCurrFileIndex] - myCurrIFile->tellg(); myCurrIFile->read((char *)(theBuffer + myCurrPos), aSizeToRead ); myCurrIFile->close(); delete(myCurrIFile); @@ -724,8 +724,8 @@ bool LightApp_Driver::PutFilesToNextStream( const std::string& theModuleName, un else // new code for big files { int aPos = myCurrIFile->tellg(); - size_t aFileSize = myFileSizes[myCurrFileIndex]; - size_t aSizeToRead = GetMaxBuffSize() - myCurrPos; + t_size aFileSize = myFileSizes[myCurrFileIndex]; + t_size aSizeToRead = GetMaxBuffSize() - myCurrPos; if ( aSizeToRead > myFileSizes[myCurrFileIndex] - myCurrIFile->tellg() ) aSizeToRead = myFileSizes[myCurrFileIndex] - myCurrIFile->tellg(); myCurrIFile->read((char *)(theBuffer + myCurrPos), aSizeToRead ); @@ -792,8 +792,8 @@ void LightApp_Driver::PutFirstStreamToFiles( ListOfFiles& theListOfFiles, const int n = myNbFilles + 1; theListOfFiles.resize( n ); - myFileSizes = new size_t[ n ]; - myFileNameSizes = new size_t[ n ]; + myFileSizes = new t_size[ n ]; + myFileNameSizes = new t_size[ n ]; theListOfFiles[ 0 ] = aDir; myFileSizes[ 0 ] = 0; myFileNameSizes[ 0 ] = 0; @@ -840,7 +840,7 @@ void LightApp_Driver::PutFirstStreamToFiles( ListOfFiles& theListOfFiles, else { // old code for big files - size_t aSize = theBufferSize - myCurrPos; + t_size aSize = theBufferSize - myCurrPos; myCurrOFile->write((char *)( theBuffer + myCurrPos ), aSize ); myFileSizes[ myCurrFileIndex ] -= aSize; myCurrPos = 0; @@ -922,8 +922,8 @@ void LightApp_Driver::PutNextStreamToFiles( ListOfFiles& theListOfFiles, else { // old code for big files - size_t aFileSize = myFileSizes[ myCurrFileIndex ]; - size_t aSize = theBufferSize - myCurrPos; + t_size aFileSize = myFileSizes[ myCurrFileIndex ]; + t_size aSize = theBufferSize - myCurrPos; myCurrOFile->write((char *)( theBuffer + myCurrPos ), aSize ); myFileSizes[ myCurrFileIndex ] -= aSize; myCurrPos = 0; diff --git a/src/LightApp/LightApp_Driver.h b/src/LightApp/LightApp_Driver.h index 25d4842be..1ef96c4e8 100644 --- a/src/LightApp/LightApp_Driver.h +++ b/src/LightApp/LightApp_Driver.h @@ -31,6 +31,8 @@ #pragma warning( disable:4251 ) #endif +typedef unsigned int t_size; + class QString; /*!Description : Driver can save to file and read from file list of files for light modules*/ @@ -76,7 +78,7 @@ protected: void PutNextStreamToFiles( ListOfFiles& theListOfFiles, const unsigned char* theBuffer, const long theBufferSize, bool theNamesOnly = false); - inline static size_t GetMaxBuffSize(); + inline static t_size GetMaxBuffSize(); std::string GetTmpDir(); std::string GetDirFromPath(const std::string& thePath); @@ -103,26 +105,26 @@ private: int myCurrFileIndex; // writing - size_t myCurrPos; + t_size myCurrPos; unsigned char* myCurrBuff; ifstream* myCurrIFile; - size_t mySizeToBeWritten; - size_t* myFileSizes; - size_t* myFileNameSizes; + t_size mySizeToBeWritten; + t_size* myFileSizes; + t_size* myFileNameSizes; // reading ofstream* myCurrOFile; long myNbFilles; }; -inline size_t LightApp_Driver::GetMaxBuffSize() +inline t_size LightApp_Driver::GetMaxBuffSize() { - static size_t aValue = 0; + static t_size aValue = 0; if ( !aValue ) { char* aVar = getenv( "HDF_BUFFER_SIZE" ); if ( aVar ) - aValue = (size_t)atol( aVar ); + aValue = (t_size)atol( aVar ); else aValue = 50000000; } diff --git a/src/SUIT/SUIT_Session.cxx b/src/SUIT/SUIT_Session.cxx index 9ab60b1ab..f263bf13b 100755 --- a/src/SUIT/SUIT_Session.cxx +++ b/src/SUIT/SUIT_Session.cxx @@ -433,9 +433,6 @@ QString SUIT_Session::getBackupFolder() const if ( var ) aRes = var; - if ( aRes.isEmpty() || !QFileInfo( aRes ).exists() ) - aRes = QDir::tempPath(); - return aRes; } @@ -530,6 +527,10 @@ void SUIT_Session::createBackupTimer() if ( !app ) return; + QString backupFolder = getBackupFolder(); + if ( backupFolder.isEmpty() ) + return; + myBTimer = new QTimer( this ); connect( myBTimer, SIGNAL( timeout() ), this, SLOT( onBTimer() ) ); @@ -537,7 +538,7 @@ void SUIT_Session::createBackupTimer() if ( mSec > 0 ) myBTimer->start( mSec ); - QString pref = QDir::convertSeparators( getBackupFolder() + "/" + getBackupPrefix() ); + QString pref = QDir::convertSeparators( backupFolder + "/" + getBackupPrefix() ); myBFolder = pref; int i = 0; do @@ -637,9 +638,13 @@ void SUIT_Session::restoreBackup() { QString pref = getBackupPrefix(); + QString bkpFold = getBackupFolder(); + if ( bkpFold .isEmpty() ) + return; + // checks whether temp folder contains old backups - QDir bkpDir( getBackupFolder() ); - + QDir bkpDir( bkpFold ); + QStringList filt; filt.append( pref + "*" ); bkpDir.setNameFilters( filt );