From 464a4da30a5664f7bef237a55f44bb8e93ff83fa Mon Sep 17 00:00:00 2001 From: Thomas McGuire Date: Sat, 16 Jan 2010 14:54:11 +0000 Subject: [PATCH] - Fix logic error I introduced myself - Less and more helpful debug svn path=/branches/work/akonadi-ports/kdepim/; revision=1075689 --- kmcomposewin.cpp | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/kmcomposewin.cpp b/kmcomposewin.cpp index b86ffca12..fd89d3b04 100644 --- a/kmcomposewin.cpp +++ b/kmcomposewin.cpp @@ -674,21 +674,19 @@ void KMComposeWin::writeAutoSaveToDisk( KMime::Message::Ptr message, int msgNum mAutoSaveUUID + "." + QString::number( msgNum ); KSaveFile file( filename ); QString errorMessage; - kDebug() << "Opening autosavefile" << filename; + kDebug() << "Writing message to disk as" << filename; if( file.open() ) { - kDebug() << "Succesfully opened autosave file."; file.setPermissions( QFile::ReadUser | QFile::WriteUser ); - kDebug() << "autosaving message in" << filename; if( file.write( message->encodedContent() ) != static_cast( message->encodedContent().size() ) ) { errorMessage = i18n( "Could not write all data to file." ); } - - kDebug() << "closing autosave file."; - if( !file.finalize() ) { - errorMessage = i18n( "Could not finalize the file." ); + else { + if( !file.finalize() ) { + errorMessage = i18n( "Could not finalize the file." ); + } } } else { @@ -696,7 +694,8 @@ void KMComposeWin::writeAutoSaveToDisk( KMime::Message::Ptr message, int msgNum } if ( !errorMessage.isEmpty() ) { - if ( mAutoSaveErrorShown == false ) { + kWarning() << "Auto saving failed:" << errorMessage << file.errorString(); + if ( !mAutoSaveErrorShown ) { KMessageBox::sorry( this, i18n( "Autosaving the message as %1 failed.\n" "%2\n" "Reason: %3", @@ -704,9 +703,15 @@ void KMComposeWin::writeAutoSaveToDisk( KMime::Message::Ptr message, int msgNum errorMessage, file.errorString() ), i18n( "autosave" ) ); + + // Error dialog shown, hide the errors the next time + mAutoSaveErrorShown = true; } } - mAutoSaveErrorShown = true; + else { + // No error occurred, the next error should be shown again + mAutoSaveErrorShown = false; + } }