check we could open the file, i always get hit by that kind of bugs in other apps and i hate it :D

svn path=/trunk/KDE/kdegraphics/okular/; revision=766417
This commit is contained in:
Albert Astals Cid 2008-01-25 20:06:02 +00:00
parent 51ca1e51c6
commit 76566e8afe

View file

@ -121,9 +121,15 @@ void EmbeddedFilesDialog::saveFile( Okular::EmbeddedFile* ef )
QFile f(path);
if ( !f.exists() || KMessageBox::warningContinueCancel( this, i18n( "A file named \"%1\" already exists. Are you sure you want to overwrite it?", path ), QString(), KGuiItem( i18n( "Overwrite" ) ) ) == KMessageBox::Continue )
{
f.open( QIODevice::WriteOnly );
f.write( ef->data() );
f.close();
if (f.open( QIODevice::WriteOnly ))
{
f.write( ef->data() );
f.close();
}
else
{
KMessageBox::error( this, i18n( "Could not open \"%1\" for writing. File was not saved.", path ) );
}
}
}