Changed AdBlockManager to load subscriptions only when it is enabled.

Wed, 03 Mar 2010 07:26:45 +0000

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 03 Mar 2010 07:26:45 +0000
changeset 132
2c870b5b485a
parent 131
60d355abbcd8
child 133
5b6e8eb22796

Changed AdBlockManager to load subscriptions only when it is enabled.

Helpviewer/AdBlock/AdBlockManager.py file | annotate | diff | comparison | revisions
--- a/Helpviewer/AdBlock/AdBlockManager.py	Sun Feb 28 17:29:01 2010 +0000
+++ b/Helpviewer/AdBlock/AdBlockManager.py	Wed Mar 03 07:26:45 2010 +0000
@@ -35,6 +35,7 @@
         QObject.__init__(self, parent)
         
         self.__loaded = False
+        self.__subscriptionsLoaded = False
         self.__enabled = False
         self.__adBlockDialog = None
         self.__adBlockNetwork = None
@@ -71,6 +72,8 @@
             return
         
         self.__enabled = enabled
+        if enabled:
+            self.__loadSubscriptions()
         self.emit(SIGNAL("rulesChanged()"))
     
     def network(self):
@@ -189,13 +192,14 @@
             return
         
         Preferences.setHelp("AdBlockEnabled", self.__enabled)
-        subscriptions = []
-        for subscription in self.__subscriptions:
-            if subscription is None:
-                continue
-            subscriptions.append(bytes(subscription.url().toEncoded()).decode())
-            subscription.saveRules()
-        Preferences.setHelp("AdBlockSubscriptions", subscriptions)
+        if self.__subscriptionsLoaded:
+            subscriptions = []
+            for subscription in self.__subscriptions:
+                if subscription is None:
+                    continue
+                subscriptions.append(bytes(subscription.url().toEncoded()).decode())
+                subscription.saveRules()
+            Preferences.setHelp("AdBlockSubscriptions", subscriptions)
     
     def load(self):
         """
@@ -207,6 +211,15 @@
         self.__loaded = True
         
         self.__enabled = Preferences.getHelp("AdBlockEnabled")
+        if self.__enabled:
+            self.__loadSubscriptions()
+    
+    def __loadSubscriptions():
+        """
+        Private method to load the set of subscriptions.
+        """
+        if self.__subscriptionsLoaded:
+            return
         
         defaultSubscriptions = []
         defaultSubscriptions.append(
@@ -225,6 +238,8 @@
             self.connect(adBlockSubscription, SIGNAL("changed()"), 
                          self, SIGNAL("rulesChanged()"))
             self.__subscriptions.append(adBlockSubscription)
+        
+        self.__subscriptionsLoaded = True
     
     def showDialog(self):
         """

eric ide

mercurial