From 9965630aaf00d81c656baff5072dda9477544d97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Tue, 19 Sep 2023 23:19:11 +0200 Subject: [PATCH] lldb: Look up Qt Creator version via Info.plist instead of mdls For some reason mdls fails to resolve the kMDItemVersion for Qt Creator in some cases, even if the Info.plist has the required version keys, and the version shows up fine in Finder. Work around it by manually reading the version from the Info.plist Fixes: QTBUG-117204 Change-Id: I60d57fb728608e139a4540fabf1006fc2681d0a7 Reviewed-by: Christian Stenger --- src/corelib/debug_script.py | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/src/corelib/debug_script.py b/src/corelib/debug_script.py index 33b32440699..b4a58530dae 100644 --- a/src/corelib/debug_script.py +++ b/src/corelib/debug_script.py @@ -47,14 +47,24 @@ def __lldb_init_module(debugger, session_dict): return versions = {} - for install in os.popen( - 'mdfind kMDItemCFBundleIdentifier=org.qt-project.qtcreator' - '| while read p;' - 'do echo $p=$(mdls "$p" -name kMDItemVersion -raw);' - 'done'): - install = install.strip() - (p, v) = install.split('=') - versions[v] = p + for path in os.popen('mdfind kMDItemCFBundleIdentifier=org.qt-project.qtcreator'): + path = path.strip() + file = open(os.path.join(path, 'Contents', 'Info.plist'), "rb") + + import plistlib + plist = plistlib.load(file) + + version = None + for key in ["CFBundleVersion", "CFBundleShortVersionString"]: + if key in plist: + version = plist[key] + break + + if not version: + print(f"Could not resolve version for '{path}'. Ignoring.") + continue + + versions[version] = path if not len(versions): print("Could not find Qt Creator installation. No Qt summary providers installed.")