commit/tipOfTheDay: derekriemer: Fix failure to terminate the add-on leaving behind artifacts.

  • From: commits-noreply@xxxxxxxxxxxxx
  • To: nvda-addons-commits@xxxxxxxxxxxxx
  • Date: Wed, 10 Aug 2016 00:23:13 -0000

1 new commit in tipOfTheDay:

https://bitbucket.org/nvdaaddonteam/tipoftheday/commits/7003e68f205a/
Changeset:   7003e68f205a
Branch:      master
User:        derekriemer
Date:        2016-08-10 00:18:26+00:00
Summary:     Fix failure to terminate the add-on leaving behind artifacts.

Affected #:  3 files

diff --git a/addon/globalPlugins/tip_of_the_day/__init__.py 
b/addon/globalPlugins/tip_of_the_day/__init__.py
index f83a51f..1cb4168 100644
--- a/addon/globalPlugins/tip_of_the_day/__init__.py
+++ b/addon/globalPlugins/tip_of_the_day/__init__.py
@@ -83,7 +83,7 @@ class GlobalPlugin(globalPluginHandler.GlobalPlugin):
                                
queueHandler.queueFunction(queueHandler.eventQueue, tipDialog.create) #This 
should queue this to open in the future when NVDA is ready.
                self.purger() #gracefully remove dead timers.
                lastUse.alert(self) # runs a timer over and over every few 
minutes, and when the specified action happens, calls -the callback specified.
-       
+
        def __call__(self): # calling this object with no arguments will work. 
This way we can use the class as the object to call.
                queueHandler.queueFunction(queueHandler.eventQueue, 
tipDialog.create) #This should queue this to open in the future when NVDA is 
ready. Seems to prevent an issue with the dialog not appearing thince this gets 
called randomly.
                lastUse = TipTimeManager(time.time())
@@ -97,6 +97,7 @@ class GlobalPlugin(globalPluginHandler.GlobalPlugin):
                for i in globalVars.TOD_timers:
                        if i.is_alive():
                                i.cancel()
+               tipDialog.terminate()
        
        def purger(self):
                        #timers might have died. Filter the global timers list 
so that dead timers can be garbage collected.

diff --git a/addon/globalPlugins/tip_of_the_day/tipDialog.py 
b/addon/globalPlugins/tip_of_the_day/tipDialog.py
index 2ee5548..752a320 100644
--- a/addon/globalPlugins/tip_of_the_day/tipDialog.py
+++ b/addon/globalPlugins/tip_of_the_day/tipDialog.py
@@ -11,6 +11,8 @@ import queueHandler
 from logHandler import log
 from tipsReader import Tips
 
+prefs = mainDialog = None
+
 def confDialog(evt = None, createAfter = False):
        conf = tipConfig.conf
        choices = [
@@ -166,18 +168,31 @@ def create():
 
 
 def initialize():
+       global prefs, mainDialog
        conf = tipConfig.conf
        if conf['user']['level'] == 'not sure': #The default pop up a dialog.
                wx.CallAfter(confDialog, createAfter = True) #pop the dialog 
when ready.
        menu = gui.mainFrame.sysTrayIcon.menu
        prefsMenu = gui.mainFrame.sysTrayIcon.preferencesMenu
        #Translators: Message for getting a tip of the day manually.
-       item = menu.Append(wx.ID_ANY, _("Tip of the day"))
+       mainDialog = item = menu.Append(wx.ID_ANY, _("Tip of the day"))
        menu.Bind(wx.EVT_MENU, onCreateTip, item)
        #Translators: Message for setting the tip of the day preferences.
-       item = prefsMenu.Append(wx.ID_ANY, _("Tip of the day settings ..."))
+       prefs = item = prefsMenu.Append(wx.ID_ANY, _("Tip of the day settings 
..."))
        menu.Bind(wx.EVT_MENU, confDialog, item)
 
+def terminate():
+       global prefs, mainDialog
+       try:
+               gui.mainFrame.sysTrayIcon.preferencesMenu.RemoveItem(prefs)
+       except wx.PyDeadObjectError:
+               pass
+       try:
+               gui.mainFrame.sysTrayIcon.menu.RemoveItem(mainDialog)
+       except wx.PyDeadObjectError:
+               pass
+
+
 def onCreateTip(evt):
        create()
 

diff --git a/buildVars.py b/buildVars.py
index 03b5858..933c03b 100644
--- a/buildVars.py
+++ b/buildVars.py
@@ -19,7 +19,7 @@ addon_info = {
        # Translators: Long description to be shown for this add-on on add-on 
information from add-ons manager
        "addon_description" : _("""The Tip of the day Addon allows beginner 
users to receive a tip of the day once a day. See it's documentation for more 
info."""),
        # version
-       "addon_version" : "1.0-dev",
+       "addon_version" : "1.0.1",
        # Author(s)
        "addon_author" : u"derek Riemer <driemer.riemer@xxxxxxxxx>",
        # URL for the add-on documentation support
@@ -33,7 +33,8 @@ import os.path
 
 # Define the python files that are the sources of your add-on.
 # You can use glob expressions here, they will be expanded.
-pythonSources = ["addon\globalPlugins"]
+baseDir = os.path.join("addon", "globalPlugins")
+pythonSources = [os.path.join(baseDir, "tip_of_the_day", "*.py"), 
os.path.join(baseDir, "tips.json")]
 
 # Files that contain strings for translation. Usually your python sources
 i18nSources = pythonSources + ["buildVars.py"]

Repository URL: https://bitbucket.org/nvdaaddonteam/tipoftheday/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.

Other related posts:

  • » commit/tipOfTheDay: derekriemer: Fix failure to terminate the add-on leaving behind artifacts. - commits-noreply