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 <christian.stenger@qt.io>
This commit is contained in:
Tor Arne Vestbø 2023-09-19 23:19:11 +02:00
parent fe3e0fc657
commit 9965630aaf

View File

@ -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.")