Squish: Avoid crash on Mac when invoking context menus

Again this is a hack to avoid AUT crashes when using Squish 5.0.1
with Qt Creator based on Qt5.2.

Change-Id: I34e35f3892cf3c1cffdc4985234562c1c6f0848b
Reviewed-by: Robert Loehning <robert.loehning@digia.com>
This commit is contained in:
Christian Stenger
2013-12-12 13:33:04 +01:00
parent 57f09e824a
commit 969e6364eb

View File

@@ -75,6 +75,13 @@ def placeCursorToLine(editor, line, isRegex=False):
def menuVisibleAtEditor(editor, menuInList): def menuVisibleAtEditor(editor, menuInList):
menuInList[0] = None menuInList[0] = None
try: try:
# Hack for Squish 5.0.1 handling menus of Qt5.2 on Mac (avoids crash) - remove asap
if platform.system() == 'Darwin':
for obj in object.topLevelObjects():
if className(obj) == "QMenu" and obj.visible and widgetContainsPoint(editor, obj.mapToGlobal(QPoint(0, 0))):
menuInList[0] = obj
return True
return False
menu = waitForObject("{type='QMenu' unnamed='1' visible='1'}", 500) menu = waitForObject("{type='QMenu' unnamed='1' visible='1'}", 500)
if platform.system() == 'Darwin': if platform.system() == 'Darwin':
menu.activateWindow() menu.activateWindow()
@@ -316,8 +323,18 @@ def validateSearchResult(expectedCount):
# this function invokes context menu and command from it # this function invokes context menu and command from it
def invokeContextMenuItem(editorArea, command1, command2 = None): def invokeContextMenuItem(editorArea, command1, command2 = None):
ctxtMenu = openContextMenuOnTextCursorPosition(editorArea) ctxtMenu = openContextMenuOnTextCursorPosition(editorArea)
if platform.system() == 'Darwin':
activateItem(ctxtMenu, command1)
else:
activateItem(waitForObjectItem(objectMap.realName(ctxtMenu), command1, 2000)) activateItem(waitForObjectItem(objectMap.realName(ctxtMenu), command1, 2000))
if command2: if command2:
# Hack for Squish 5.0.1 handling menus of Qt5.2 on Mac (avoids crash) - remove asap
if platform.system() == 'Darwin':
for obj in object.topLevelObjects():
if className(obj) == 'QMenu' and obj.visible and not obj == ctxtMenu:
activateItem(obj, command2)
break
else:
activateItem(waitForObjectItem("{title='%s' type='QMenu' visible='1' window=%s}" activateItem(waitForObjectItem("{title='%s' type='QMenu' visible='1' window=%s}"
% (command1, objectMap.realName(ctxtMenu)), command2, 2000)) % (command1, objectMap.realName(ctxtMenu)), command2, 2000))