VCFB remebers unsaved document in the opened document list
Status: Alpha
Brought to you by:
ddiego
Let's say you create a new document with VCFB
Then you just close the application without saving it.
VCFB saves Document4
( 4 or other number )
in the list of previously opened
documents. ( it shouldn't IMO ).
This can lead to other problems.
Logged In: YES
user_id=210040
Here is the fix.
It seems to me that the list of opened documents saves them
with their full path name.
So we just need to do a check to see if we are saving a
relative path.
void WorkspaceDocument::savePreferences( Preferences*
preferences )
{
// just show the while
while ( it != openedDocuments.end() ) {
String fileName = (*it)->getFileName();
if ( !FilePath( fileName ).isRelativePath() ) { //MP-
preferences->writeString( "OpenDocument" +
StringUtils::toString( (it -
openedDocuments.begin()) + 1),
fileName );
}
it ++;
}
}
and:
void WorkspaceDocument::readPreferences( Preferences*
preferences )
{
// just the try
try {
if ( !FilePath( fileName ).isRelativePath() ) { // MP-
DocumentManager::getDocumentManager()->openFromFileName(
fileName );
}
int placeHolder_workaround = 0; // workaround for
Microsoft bug
}
catch ( BasicException& e ) {
app->pluginOuput( "Error opening \"" + fileName +
"\"\nException:\n" + e.getMessage() );
}
}
The check must be on the savePreferences function.
But it should be on the readPreferences too so to avoid any
problems ( which would be difficult to fix for the user ).
.
Logged In: YES
user_id=210040
A note about the line:
int placeHolder_workaround = 0; // workaround for
Microsoft bug
If you don't the code inside the if will be executed anyway
even if the if is false.
This is a Microsoft bug existing, pretty sure about, since
the version 6.
If you do a simple test case like:
int main(int argc, char *argv[])
{
Application* app = new AdvancedAlignmentApplication( argc,
argv );
String fileName( L"Document" );
try {
if ( !FilePath( fileName ).isRelativePath() ) {
Dialog::showMessage( "Trying to open \"" + fileName + "\"" );
}
}
catch ( ... ) {
Dialog::showMessage( "Unknown error while opening \"" +
fileName + "\"" );
}
Application::main();
return 0;
}
you don't see it !
But it happens sometimes and I never found a different way
to go around it.
What happens is that the compiler is not doing well the
calculation of where to jump, when the if is false, inside a
try block if it has only that if condition.
Logged In: YES
user_id=210040
Fixed.
I committed a code similar to the one described before.
Logged In: YES
user_id=7743
I have fixed this. As you mentioned in the earleir bugs,
this is actually a problem in the VCF, and the fact that the
DocumentManager was NOT checking to see if the file even
existed before opening it.