diff options
author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2020-08-05 10:31:35 +0200 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2020-08-05 22:15:33 +0200 |
commit | 512c2cf2fb9d3f2a530769540adfe84387b57f07 (patch) | |
tree | 3ae854b66ad6d47054a955921e66d8068d0c1016 | |
parent | 35ecd0b69d58bcc8113afc5e449aef841c73e26c (diff) |
Teach QMacVersion to deal with 32-bit Mach-O headers
Change-Id: I7946aa35722bc76326e2d6cf0820353c4ba13fad
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
(cherry picked from commit b6de6a96990577f8041ba1520bd0f2766be6027c)
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoahelpers.h | 4 | ||||
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoahelpers.mm | 4 |
2 files changed, 3 insertions, 5 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoahelpers.h b/src/plugins/platforms/cocoa/qcocoahelpers.h index 456129ffec..22ea569c67 100644 --- a/src/plugins/platforms/cocoa/qcocoahelpers.h +++ b/src/plugins/platforms/cocoa/qcocoahelpers.h @@ -178,10 +178,6 @@ T qt_mac_resolveOption(const T &fallback, QWindow *window, const QByteArray &pro // ------------------------------------------------------------------------- -#if QT_POINTER_SIZE == 4 -#error "32-bit builds are not supported" -#endif - class QMacVersion { public: diff --git a/src/plugins/platforms/cocoa/qcocoahelpers.mm b/src/plugins/platforms/cocoa/qcocoahelpers.mm index 240f184be4..2048bccf65 100644 --- a/src/plugins/platforms/cocoa/qcocoahelpers.mm +++ b/src/plugins/platforms/cocoa/qcocoahelpers.mm @@ -406,7 +406,9 @@ QMacVersion::VersionTuple QMacVersion::versionsForImage(const mach_header *machH ); }; - auto commandCursor = uintptr_t(machHeader) + sizeof(mach_header_64); + const bool is64Bit = machHeader->magic == MH_MAGIC_64 || machHeader->magic == MH_CIGAM_64; + auto commandCursor = uintptr_t(machHeader) + (is64Bit ? sizeof(mach_header_64) : sizeof(mach_header)); + for (uint32_t i = 0; i < machHeader->ncmds; ++i) { load_command *loadCommand = reinterpret_cast<load_command *>(commandCursor); if (loadCommand->cmd == LC_VERSION_MIN_MACOSX) { |