[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kdelibs/frameworks] tier1/kwidgetsaddons/src: Store default KMessageBox interface implementations w
From:       Aurélien Gâteau <agateau () kde ! org>
Date:       2013-10-23 9:48:44
Message-ID: E1VYv3U-00076D-B5 () scm ! kde ! org
[Download RAW message or body]

Git commit 9caaa8e7bb6f7083765d9971f29f29c550a8cb13 by Aurélien Gâteau.
Committed on 22/10/2013 at 15:01.
Pushed by gateau into branch 'frameworks'.

Store default KMessageBox interface implementations with Q_GLOBAL_STATIC

Document ownership of the implementations in the setter methods.

Reviewed-by: dfaure

M  +4    -2    tier1/kwidgetsaddons/src/kmessagebox.h
M  +5    -5    tier1/kwidgetsaddons/src/kmessagebox_p.cpp

http://commits.kde.org/kdelibs/9caaa8e7bb6f7083765d9971f29f29c550a8cb13

diff --git a/tier1/kwidgetsaddons/src/kmessagebox.h \
b/tier1/kwidgetsaddons/src/kmessagebox.h index 4d3c7cf..cb5928a 100644
--- a/tier1/kwidgetsaddons/src/kmessagebox.h
+++ b/tier1/kwidgetsaddons/src/kmessagebox.h
@@ -789,14 +789,16 @@ namespace KMessageBox
     KWIDGETSADDONS_EXPORT void setDontShowAgainConfig(KConfig* cfg);
 
     /**
-     * Use @p dontAskAgainInterface for all settings related to the donShowAgain \
feature +     * Use @p dontAskAgainInterface for all settings related to the \
donShowAgain feature. +     * This method does not take ownership of @p \
                dontAskAgainInterface.
      *
      * @since 5.0
      */
     KWIDGETSADDONS_EXPORT void \
setDontShowAgainInterface(KMessageBoxDontAskAgainInterface* dontAskAgainInterface);  
     /**
-     * Use @p notifyInterface to send notifications
+     * Use @p notifyInterface to send notifications.
+     * This method does not take ownership of @p notifyInterface.
      *
      * @since 5.0
      */
diff --git a/tier1/kwidgetsaddons/src/kmessagebox_p.cpp \
b/tier1/kwidgetsaddons/src/kmessagebox_p.cpp index b4ecb3e..c0bcf80 100644
--- a/tier1/kwidgetsaddons/src/kmessagebox_p.cpp
+++ b/tier1/kwidgetsaddons/src/kmessagebox_p.cpp
@@ -67,7 +67,9 @@ public:
     void sendNotification(QMessageBox::Icon /*notificationType*/, const QString \
&/*message*/, QWidget */*parent*/) {}  };
 
-// TODO should we use QSharedPointer here?
+Q_GLOBAL_STATIC(KMessageBoxDontAskAgainMemoryStorage, \
s_defaultDontAskAgainInterface); +Q_GLOBAL_STATIC(KMessageBoxNotifyDummy, \
s_defaultNotifyInterface); +
 static KMessageBoxDontAskAgainInterface* s_dontAskAgainInterface = 0;
 static KMessageBoxNotifyInterface* s_notifyInterface = 0;
 
@@ -84,12 +86,11 @@ static void loadKMessageBoxPlugin()
             s_notifyInterface = \
rootObj->property(KMESSAGEBOXNOTIFY_PROPERTY).value<KMessageBoxNotifyInterface *>();  \
}  }
-    // TODO use Qt-5.1's Q_GLOBAL_STATIC
     if (!s_dontAskAgainInterface) {
-        s_dontAskAgainInterface = new KMessageBoxDontAskAgainMemoryStorage;
+        s_dontAskAgainInterface = s_defaultDontAskAgainInterface;
     }
     if (!s_notifyInterface) {
-        s_notifyInterface = new KMessageBoxNotifyDummy;
+        s_notifyInterface = s_defaultNotifyInterface;
     }
 }
 
@@ -112,7 +113,6 @@ KMessageBoxNotifyInterface *notifyInterface()
 void setDontShowAgainInterface(KMessageBoxDontAskAgainInterface* \
dontAskAgainInterface)  {
     Q_ASSERT(dontAskAgainInterface != 0);
-    // FIXME should we delete s_dontAskAgainInterface before? Or perhaps use smart \
pointers to avoid problems?  s_dontAskAgainInterface = dontAskAgainInterface;
 }
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic