Same file modified by two users

Started by Andrés Chandía, July 19, 2010, 03:59:56 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Liviu Lalescu

I think I solved it (compile attached files).

There may still be bugs in my source, so please:

1) Compare by contents the official files and these files, and try to think if my code is correct.
2) Test much before relying to it as a safe function.
3) Don't be angry at me if I still forgot some situations and you get data loss. I'll try to fix the problems if you report them.

Andrés Chandía

Thanks a lot Liviu, I will try the code, and check it, to send you a kind of inform of the situation, It will be run under windows XP.
@ch

Andrés Chandía

Liviu, it was a complete success!!!!!

Thanks a lot SENSEI Liviu, I sent a memo to my boss letting her know that you've made the magic, for her to remember the pending stuff about donations.

Well now, some more little things, if it possible, instead letting people save the file with a different name, could it be so blocked that the user find himself forced to close the file and retry later. Something like "File in use, Retry Later!"

And thanks again.
@ch

Liviu Lalescu

In file fetmainform.cpp, after line 899 ("{"), insert:


if(readOnly){
      QMessageBox::warning(this, tr(FET warning"), tr("File is in use by another user - cannot save"));
      return false;
}


and modify line 1354 (change the message "This file is in use..."). This is line 1354 before inserting the code above.

I hope I did no mistakes.

Andrés Chandía

It gives me this error:


interface\fetmainform.cpp:901:100: warning: missing terminating " character
interface\fetmainform.cpp:901: error: missing terminating " character
interface\fetmainform.cpp: In member function 'bool FetMainForm::fileSaveAs()':
interface\fetmainform.cpp:901: error: 'FET' was not declared in this scope
mingw32-make[2]: *** [../tmp/fetmainform.o] Error 1
mingw32-make[2]: Leaving directory `C:/Programa-FET/src'
mingw32-make[1]: *** [release] Error 2
mingw32-make[1]: Leaving directory `C:/Programa-FET/src'
mingw32-make: *** [sub-src-make_default] Error 2


I've edited the file this way (the first line in this extract being 891:

           if(INPUT_FILENAME_XML!="" && !readOnly)
                 setWindowTitle(tr("FET - %1", "The title of the main window, %1 is the name of the current file").arg(INPUT_FILENAME_XML.right(INPUT_FILENAME_XML.length()-INPUT_FILENAME_XML.findRev("/")-1)));
           else if(INPUT_FILENAME_XML!="" && readOnly)
                 setWindowTitle(tr("FET - %1 [READ_ONLY]", "The title of the main window, %1 is the name of the current file").arg(INPUT_FILENAME_XML.right(INPUT_FILENAME_XML.length()-INPUT_FILENAME_XML.findRev("/")-1)));
     }
}

bool FetMainForm::fileSaveAs()
{
if(readOnly){
      QMessageBox::warning(this, tr(FET warning"), tr("File is in use by another user - cannot save"));
      return false;
}
     QString predefFileName=INPUT_FILENAME_XML;
     if(predefFileName=="")
           predefFileName=WORKING_DIRECTORY+FILE_SEP+"untitled.fet";
@ch

Liviu Lalescu

Sorry, it should be:


if(readOnly){
      QMessageBox::warning(this, tr("FET warning"), tr("File is in use by another user - cannot save"));
      return false;
}


(add a " before FET warning text).

Andrés Chandía

Ok, as long as I tested was OK, I will make it available for users now.

Thanks again Liviu
@ch