File r905542.diff of Package kdepimlibs4
Subject: fix an infinite
password-loading loop in certain situations
From: wstephenson@suse.de
Bug: kde#170728
Patch-upstream: 905542
--- mailtransport/transport.h (revision 905541)
+++ mailtransport/transport.h (revision 905542)
@@ -61,6 +61,17 @@ class MAILTRANSPORT_EXPORT Transport : p
void setPassword( const QString &passwd );
/**
+ This function syncronizes the password of this transport with the password of the
+ transport with the same ID that is managed by the transport manager.
+ This is only useful for cloned transports, since their passwords don't automatically
+ get updated when calling TransportManager::loadPasswordsAsync() or
+ TransportManager::loadPasswords().
+
+ @sa clone()
+ */
+ void updatePasswordState();
+
+ /**
Returns true if all settings have been loaded.
This is the way to find out if the password has already been loaded
from the wallet.
@@ -77,6 +88,8 @@ class MAILTRANSPORT_EXPORT Transport : p
automatically updated. Use this if you need to store a Transport object
over a longer time. However it is recommended to store transport identifiers
instead if possible.
+
+ @sa updatePasswordState()
*/
Transport *clone() const;
--- mailtransport/transportconfigdialog.cpp (revision 905541)
+++ mailtransport/transportconfigdialog.cpp (revision 905542)
@@ -287,6 +287,9 @@ void TransportConfigDialog::passwordsLoa
{
Q_ASSERT( d->passwordEdit );
+ // Load the password from the original to our cloned copy
+ d->transport->updatePasswordState();
+
if ( d->passwordEdit->text().isEmpty() ) {
d->passwordEdit->setText( d->transport->password() );
}
--- mailtransport/transport.cpp (revision 905541)
+++ mailtransport/transport.cpp (revision 905542)
@@ -88,6 +88,22 @@ void Transport::setPassword( const QStri
d->password = passwd;
}
+void Transport::updatePasswordState()
+{
+ Transport *original = TransportManager::self()->transportById( id(), false );
+ if ( original == this ) {
+ kWarning() << "Tried to update password state of non-cloned transport.";
+ return;
+ }
+ if ( original ) {
+ d->password = original->d->password;
+ d->passwordLoaded = original->d->passwordLoaded;
+ d->passwordDirty = original->d->passwordDirty;
+ }
+ else
+ kWarning() << "Transport with this ID not managed by transport manager.";
+}
+
bool Transport::isComplete() const
{
return !requiresAuthentication() || !storePassword() || d->passwordLoaded;
--- mailtransport/transportmanager.h (revision 905541)
+++ mailtransport/transportmanager.h (revision 905542)
@@ -194,6 +194,8 @@ class MAILTRANSPORT_EXPORT TransportMana
/**
Emitted when passwords have been loaded from the wallet.
+ If you made a deep copy of a transport, you should call updatePasswordState()
+ for the cloned transport to ensure its password is updated as well.
*/
void passwordsChanged();
Index: mailtransport/transport.h
===================================================================
Index: mailtransport/transportconfigdialog.cpp
===================================================================
Index: mailtransport/transport.cpp
===================================================================
Index: mailtransport/transportmanager.h
===================================================================