Skip to content

Commit abd6889

Browse files
authored
Merge 14224b3 into cdd37c7
2 parents cdd37c7 + 14224b3 commit abd6889

1 file changed

Lines changed: 19 additions & 9 deletions

File tree

source/appModules/foobar2000.py

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
# A part of NonVisual Desktop Access (NVDA)
2-
# Copyright (C) 2009-2018 NV Access Limited, Aleksey Sadovoy, James Teh, Joseph Lee, Tuukka Ojala
3-
# This file may be used under the terms of the GNU General Public License, version 2 or later.
4-
# For more details see: https://www.gnu.org/licenses/gpl-2.0.htmlimport appModuleHandler
2+
# Copyright (C) 2009-2020 NV Access Limited, Aleksey Sadovoy, James Teh, Joseph Lee, Tuukka Ojala
3+
# This file is covered by the GNU General Public License.
4+
# See the file COPYING for more details.
55

6+
import appModuleHandler
67
import calendar
78
import collections
89
import time
9-
1010
import api
11-
import appModuleHandler
11+
from NVDAObjects.IAccessible import getNVDAObjectFromEvent
1212
import ui
13+
import windowUtils
14+
import winUser
1315

1416
# A named tuple for holding the elapsed and total playing times from Foobar2000's status bar
1517
statusBarTimes = collections.namedtuple('StatusBarTimes', ['elapsed', 'total'])
@@ -41,11 +43,19 @@ def parseIntervalToTimestamp(interval):
4143
return calendar.timegm(time.strptime(interval.strip(), format))
4244

4345
class AppModule(appModuleHandler.AppModule):
44-
statusBar=None
4546

46-
def event_gainFocus(self, obj, nextHandler):
47-
if not self.statusBar: self.statusBar=api.getStatusBar()
48-
nextHandler()
47+
def _get_statusBar(self):
48+
# #11082: retrieve status bar handle and resulting NVDA object from playlist window.
49+
# If only default status bar routine is used to assign status bar object, it can result in recursion limit error.
50+
try:
51+
statusBarHwnd = windowUtils.findDescendantWindow(
52+
api.getForegroundObject().windowHandle,
53+
className="ATL:msctls_statusbar32"
54+
)
55+
except LookupError:
56+
# No status bar handle from places other than playlist window.
57+
return None
58+
return getNVDAObjectFromEvent(statusBarHwnd, winUser.OBJID_CLIENT, 0)
4959

5060
def getElapsedAndTotal(self):
5161
empty = statusBarTimes(None, None)

0 commit comments

Comments
 (0)