[SCM] ktp-common-internals packaging branch, master, updated. debian/15.12.1-2-1839-gf0635e9

Maximiliano Curia maxy at moszumanska.debian.org
Mon May 9 09:05:53 UTC 2016


Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-common-internals.git;a=commitdiff;h=c086a55

The following commit has been merged in the master branch:
commit c086a55bb68b932348f68711f38684cbd12d2da7
Author: Daniele E. Domenichelli <daniele.domenichelli at gmail.com>
Date:   Thu Nov 22 21:25:34 2012 +0100

    Avoid calling KWallet::openWallet several times
    
    In order to avoid the problem when kwallet is closed while kcm accounts
    is open, we introduced a bug: if more than one openWallet call is done
    at the same time, we reset the scoped pointer with a new wallet, the
    old wallet is deleted and therefore the signal is never emitted.
    
    This patch uses avoids trying to open the wallet several times if it is
    already being opened.
    
    Reviewed-by: George Kiagiadakis <george.kiagiadakis at collabora.com>
    REVIEW: 107426
    BUG: 310505
    FIXED-IN: 0.5.2
---
 KTp/wallet-interface.cpp | 36 ++++++++++++++++++++++++++++++------
 1 file changed, 30 insertions(+), 6 deletions(-)

diff --git a/KTp/wallet-interface.cpp b/KTp/wallet-interface.cpp
index 428c02e..575cdf1 100644
--- a/KTp/wallet-interface.cpp
+++ b/KTp/wallet-interface.cpp
@@ -25,8 +25,10 @@
 #include <KGlobal>
 
 
-class KTp::WalletInterfacePrivate
+class KTp::WalletInterfacePrivate : public QObject
 {
+    Q_OBJECT
+
 public:
     WalletInterfacePrivate();
     void ensureWalletIsReady();
@@ -34,6 +36,11 @@ public:
     QScopedPointer<KWallet::Wallet> wallet;
     static const QLatin1String folderName;
     static const QLatin1String mapsPrefix;
+
+    bool isOpening;
+
+private Q_SLOTS:
+    void onWalletOpened(bool success);
 };
 
 using KTp::WalletInterface;
@@ -46,15 +53,22 @@ void WalletInterfacePrivate::ensureWalletIsReady()
 {
     // If wallet was force-closed since last WalletInterface::openWallet(),
     // try to reopen it.
-    if (wallet && !wallet->isOpen()) {
-	wallet.reset(KWallet::Wallet::openWallet(KWallet::Wallet::NetworkWallet(), 0, KWallet::Wallet::Asynchronous));
+    if (!wallet || !wallet->isOpen()) {
+        // If the wallet is not already being opened, we try to open it
+        if (!isOpening) {
+            isOpening = true;
+            wallet.reset(KWallet::Wallet::openWallet(KWallet::Wallet::NetworkWallet(), 0, KWallet::Wallet::Asynchronous));
+            connect(wallet.data(), SIGNAL(walletOpened(bool)), SLOT(onWalletOpened(bool)));
+        }
     }
 }
 
 
 WalletInterfacePrivate::WalletInterfacePrivate() :
-    wallet(KWallet::Wallet::openWallet(KWallet::Wallet::NetworkWallet(), 0, KWallet::Wallet::Asynchronous))
+    wallet(NULL),
+    isOpening(false)
 {
+    ensureWalletIsReady();
 }
 
 KTp::PendingWallet* WalletInterface::openWallet()
@@ -65,9 +79,19 @@ KTp::PendingWallet* WalletInterface::openWallet()
     return new PendingWallet(s_instance);
 }
 
+void WalletInterfacePrivate::onWalletOpened(bool success)
+{
+    if (!success) {
+        kWarning() << "Couldn't open wallet";
+    }
+
+    disconnect(wallet.data(), SIGNAL(walletOpened(bool)), this, SLOT(onWalletOpened(bool)));
+    isOpening = false;
+}
+
 
 WalletInterface::WalletInterface():
-    d (new WalletInterfacePrivate)
+    d(new WalletInterfacePrivate)
 {
 }
 
@@ -268,4 +292,4 @@ KWallet::Wallet *WalletInterface::wallet() const
     return d->wallet.data();
 }
 
-
+#include "wallet-interface.moc"

-- 
ktp-common-internals packaging



More information about the pkg-kde-commits mailing list