Changes in Xcode 11 Objective-C Runtime cause an error (#16387) during building on MacOS 10.15 Catalina.
This PR fixes this issue by replacing objc_msgSend()
function calls with the native Objective-C syntax.
Refs:
Changes in Xcode 11 Objective-C Runtime cause an error (#16387) during building on MacOS 10.15 Catalina.
This PR fixes this issue by replacing objc_msgSend()
function calls with the native Objective-C syntax.
Refs:
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
Reviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.
I can confirm 77dabca still builds on macOS Mojave 10.14.6. It also fixes the build for me on macOS Catalina 10.15 beta 3.
Conversely you can reproduce the error in Mojave by setting -DOBJC_OLD_DISPATCH_PROTOTYPES=0
.
I suggest tagging this 0.19, but hold off merging in favor of a solution that uses the new syntax. Apple deprecated this back in 2015.
I suggest tagging this 0.19, but hold off merging in favor of a solution that uses the new syntax. Apple deprecated this back in 2015.
Done, agree here.
I suggest tagging this 0.19, but hold off merging in favor of a solution that uses the new syntax.
Done with the native Objective-C syntax.
-DOBJC_OLD_DISPATCH_PROTOTYPES=0
for good measure?
42@@ -44,3 +43,12 @@ void setupDockClickHandler() {
43 {
44 delete s_instance;
45 }
46+
47+/**
48+ * Force application activation on macOS. With Qt 5.4 this is required when
Is there a Qt version where it’s no-longer necessary?
Looking through the Qt code base:
since Qt 5.3: https://github.com/qt/qtbase/blob/5.3/src/plugins/platforms/cocoa/qcocoaintegration.mm#L299
since Qt 5.6: https://github.com/qt/qtbase/blob/5.6/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm#L299
since Qt 5.8: https://github.com/qt/qtbase/blob/5.8/src/plugins/platforms/cocoa/qcocoawindow.mm#L1013
I suppose the workaround is not needed on Qt 5.6+. But I have no capabilities to test this hypothesis now.
I didn’t try removing the workaround altogether.
I did. It works as expected on Catalina (Beta 3) + Qt 5.13.
57@@ -58,9 +58,10 @@
58 #pragma GCC diagnostic push
59 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
60
61-#include <objc/objc-runtime.h>
62 #include <CoreServices/CoreServices.h>
63 #include <QProcess>
64+
65+void ForceActivation();
macdockiconhandler.h
and include this header instead?
When I noticed the function declaration it was not immediately obvious why the corresponding definition was not in the same cpp file. It was only obvious why it is as it is after I found the corresponding function definition in the mackdockiconhandler.mm
file.
I thought that by declaring the function in the mackdockiconhandler.h
header file and keeping the declaration and definition close to each other, it would save the next person from wondering the same.
But perhaps it just me. I am afraid I don’t have a better argument.
19@@ -21,9 +20,9 @@ bool dockClickHandler(id self, SEL _cmd, ...) {
20 }
21
22 void setupDockClickHandler() {
23- id app = objc_msgSend((id)objc_getClass("NSApplication"), sel_registerName("sharedApplication"));
24- id delegate = objc_msgSend(app, sel_registerName("delegate"));
25- Class delClass = (Class)objc_msgSend(delegate, sel_registerName("class"));
26+ id app = [NSApplication sharedApplication];
27+ id delegate = [app delegate];
28+ Class delClass = (Class)[delegate class];
id app = ...; id delegate = ...; Class delClass = ...;
to Class delClass = [NSApplication.sharedApplication.delegate class];
?
As dot notation is present in both C++ and Objective-C syntaxes, I’d prefer to keep the native Objective-C code as different from C++’s one as possible in mixed “Objective-C++” source files.
The suggestion to combine some statements into the single one will be implemented.
utACK 0bb33b5348dbddd65b88a7f00449c965562355d3 - Confirmed that the called macOS framework function is available on our build targets.
Travis error is irrelevant.
objc_msgSend
function calls to the appropriate function signature (which would also have fixed the issue).
hebasto
DrahtBot
Sjors
laanwj
fanquake
l2a5b1
jonasschnelli
Labels
macOS
Build system
Milestone
0.19.0