From a6c1f94cef9d922e10ce6ce6644ec7e5a41fd72b Mon Sep 17 00:00:00 2001 From: Frank Osterfeld Date: Mon, 22 Jul 2013 20:01:37 +0200 Subject: [PATCH] The early return catches the bug --- keychain_dbus.cpp | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/keychain_dbus.cpp b/keychain_dbus.cpp index d8c746b..29d263c 100644 --- a/keychain_dbus.cpp +++ b/keychain_dbus.cpp @@ -388,26 +388,27 @@ void WritePasswordJobPrivate::fallbackOnError(const QDBusError &err) std::auto_ptr local( !q->settings() ? new QSettings( q->service() ) : 0 ); QSettings* actual = q->settings() ? q->settings() : local.get(); - if ( q->insecureFallback() ) { - if ( mode == Delete ) { - actual->remove( key ); - actual->sync(); + if ( !q->insecureFallback() ) { + q->emitFinishedWithError( OtherError, tr("Could not open wallet: %1; %2").arg( QDBusError::errorString( err.type() ), err.message() ) ); + return; + } - q->emitFinished(); - return; - } - - actual->setValue( QString( "%1/type" ).arg( key ), (int)mode ); - if ( mode == Text ) - actual->setValue( QString( "%1/data" ).arg( key ), textData.toUtf8() ); - else if ( mode == Binary ) - actual->setValue( QString( "%1/data" ).arg( key ), binaryData ); + if ( mode == Delete ) { + actual->remove( key ); actual->sync(); q->emitFinished(); - } else { - q->emitFinishedWithError( OtherError, tr("Could not open wallet: %1; %2").arg( QDBusError::errorString( err.type() ), err.message() ) ); - } + return; + } + + actual->setValue( QString( "%1/type" ).arg( key ), (int)mode ); + if ( mode == Text ) + actual->setValue( QString( "%1/data" ).arg( key ), textData.toUtf8() ); + else if ( mode == Binary ) + actual->setValue( QString( "%1/data" ).arg( key ), binaryData ); + actual->sync(); + + q->emitFinished(); } void WritePasswordJobPrivate::gnomeKeyring_cb( int result, WritePasswordJobPrivate* self )