[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: kdepim/certmanager/lib/backends/qgpgme
From: David Faure <faure () kde ! org>
Date: 2004-03-12 13:35:57
Message-ID: 20040312133557.4A24499AC () office ! kde ! org
[Download RAW message or body]
CVS commit by faure:
Doh! Fixed test in destructor (Steffen: it was probably a false positive).
Also improved error handling.
M +24 -7 qgpgmecryptoconfig.cpp 1.16
M +1 -1 qgpgmecryptoconfig.h 1.9
--- kdepim/certmanager/lib/backends/qgpgme/qgpgmecryptoconfig.cpp #1.15:1.16
@@ -235,6 +235,7 @@ void QGpgMECryptoConfigComponent::sync(
tmpFile.setAutoDelete( true );
+ QValueList<QGpgMECryptoConfigEntry *> dirtyEntries;
+
// Collect all dirty entries
- bool foundOne = false;
QDictIterator<QGpgMECryptoConfigGroup> groupit( mGroups );
for( ; groupit.current(); ++groupit ) {
@@ -242,5 +243,4 @@ void QGpgMECryptoConfigComponent::sync(
for( ; it.current(); ++it ) {
if ( it.current()->isDirty() ) {
- foundOne = true;
// OK, we can set it.currentKey() to it.current()->outputString()
QString line = it.currentKey();
@@ -254,10 +254,10 @@ void QGpgMECryptoConfigComponent::sync(
QCString line8bit = line.latin1(); // latin1 is correct here, it's all \
escaped (and KProcIO uses latin1 when reading).
tmpFile.file()->writeBlock( line8bit.data(), line8bit.size()-1 /*no 0*/ );
- it.current()->setDirty( false ); // ### move to after running gpgconf, on \
success only? + dirtyEntries.append( it.current() );
}
}
}
tmpFile.close();
- if ( !foundOne )
+ if ( dirtyEntries.isEmpty() )
return;
@@ -286,6 +286,17 @@ void QGpgMECryptoConfigComponent::sync(
// ####### TODO error handling (message box).
- if( rc != 0 ) // Happens due to bugs in gpgconf (e.g. issue104)
+ if( rc != 0 ) // Happens due to bugs in gpgconf (e.g. issues 104/115)
+ {
+ QString wmsg = i18n( "Error from gpgconf while saving configuration: %1" ).arg( \
strerror( rc ) ); + KMessageBox::error(0, wmsg);
kdWarning(5150) << k_funcinfo << ":" << strerror( rc ) << endl;
+ }
+ else
+ {
+ QValueList<QGpgMECryptoConfigEntry *>::Iterator it = dirtyEntries.begin();
+ for( ; it != dirtyEntries.end(); ++it ) {
+ (*it)->setDirty( false );
+ }
+ }
}
@@ -434,6 +445,7 @@ QGpgMECryptoConfigEntry::~QGpgMECryptoCo
{
#ifndef NDEBUG
- if ( !s_duringClear && !mDirty )
- kdWarning(5150) << "Deleting a QGpgMECryptoConfigEntry that was modified. You \
forgot to call sync() (to commit) or clear() (to discard)" << endl; + if ( \
!s_duringClear && mDirty ) + kdWarning(5150) << "Deleting a \
QGpgMECryptoConfigEntry that was modified (" << mDescription << ")\n" + \
<< "You forgot to call sync() (to commit) or clear() (to discard)" << endl; #endif
}
@@ -747,3 +759,8 @@ bool QGpgMECryptoConfigEntry::isStringTy
}
+void QGpgMECryptoConfigEntry::setDirty( bool b )
+{
+ mDirty = b;
+}
+
#include "qgpgmecryptoconfig.moc"
--- kdepim/certmanager/lib/backends/qgpgme/qgpgmecryptoconfig.h #1.8:1.9
@@ -156,5 +156,5 @@ public:
virtual void setURLValueList( const KURL::List& );
virtual bool isDirty() const { return mDirty; }
- void setDirty( bool b ) { mDirty = b; }
+ void setDirty( bool b );
QString outputString() const;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic