Solved Inherited QGuiApplication object do not working on iOS Simulator. Why?
-
@bogong Did you try to debug on simulator? Stack trace could provide more information about what is happening.
-
@SGaist that whole class is in previous message.
-
@jsulm No any errors in debug mode. In debug mode just freeze on system launch-screen. Only this:
In following objects map. It's creating but not working properly.
-
@jsulm And this what I see on real device for the same project, everything works fine:
-
And there was no any troubles on 5.12.4 version. I am doing what I've been doing always - inheriting QGuiApplication for future defining event filter. Nothing more. It's working everywhere but not in iOS Simulator.
-
Just tested on other MacOS workstation. Everything works fine for all platforms. The troubles with simulator on one computer. Might be after downgraded XCode after update.
-
I've been wrong in previous message. Just reinstalled on Qt 5.12.5 and Xcode 10.3 from scratch on clean and totally erased MacBook. The same result it's not working only on iOS Simulator. When I ran it in XCode directly - got this error:
Why it might be only in iOS simulator? Every other platform working perfectly.
-
@bogong said in Inherited QGuiApplication object do not working on iOS Simulator. Why?:
CustomGuiApplication::CustomGuiApplication(int inCounter,char *inArguments[]) : QGuiApplication(inCounter, inArguments) { }
is wrong. The argc must be passed by reference, not by value. Also a friendly piece of advice - don't inherit from
QXXXApplication
for no good reason at all ... -
@kshegunov ??? But why it's working everywhere else but not in iOS Simulator only??? And why it's working on 5.12.4 but not in Qt 5.12.5 and 5.13.1??? Why do the error looks like architecture trouble but not application??? Why has it been working at least for 5 applications since 2014???
-
Are we arguing now?
But why it's working everywhere else but not in iOS Simulator only???
Even if it worked on every other platform beside X, then it's not working, exactly because it doesn't work on X. You can't have it both ways, it either works, or it doesn't. If it works then it works everywhere, if it's broke sometimes then it doesn't work.
Why do the error looks like architecture trouble but not application???
Oh, no, it's user-code error.
Compare signatures: https://doc.qt.io/qt-5/qcoreapplication.html#QCoreApplication -
@kshegunov This *inArguments[] totally equal **inArguments ... It was BTW ... And it's working on Linux, Windows, MacOS and iOS device but not on iOS Simulator only ...
-
@bogong said in Inherited QGuiApplication object do not working on iOS Simulator. Why?:
This *inArguments[] totally equal **inArguments
Yes, the former decays to the latter, but as I said originally
int &
is very different fromint
. -
One important thing, your constructor signature is wrong. See here, it's a reference to an int not an int for argc.
-
@kshegunov And how it explain that is not working on iOS Simulator only??? Is there special C++ syntax for iOS Simulator??? I mean if I am wrong - OK, but why it's crashing on iOS Simulator only but not everywhere?
-
@bogong said in Inherited QGuiApplication object do not working on iOS Simulator. Why?:
And how it explain that is not working on iOS Simulator only???
You've been relying on an implementation detail (and possibly undefined behavior).
Let me put this into an example:static SomeClass global1 = SomeClass(0); static OtherClass global2 = OtherClass(global1); int main(...) { ... }
Seems legit, right? Well it's not, the moment
global2
touchesglobal1
you're in undefined behavior land. The order of (nontrivial) statics intialization is undefined. So even if it works on 100 different platforms, it's still broke, and when the 101st actually breaks it, you don't say - "well it worked 100 times, so there's something wrong with 101st", you say "damn, I had the rotten luck of it working 100 times before it showed its ugly fangs and horns".[1]Is there special C++ syntax for iOS Simulator???
Of course not, but you've not satisfied the requirements put forward by the framework - that is you've passed a local copy instead of the original variable holding the number of arguments.
[1]: https://en.wikipedia.org/wiki/Thirteenth_stroke_of_the_clock
-
@kshegunov I mean if I am wrong - OK, but why it's crashing on iOS Simulator ONLY but not everywhere? In following your explanation it should be crashing everywhere but it's not.
-
@bogong said in Inherited QGuiApplication object do not working on iOS Simulator. Why?:
@kshegunov I mean if I am wrong - OK
You're wrong. But don't feel bad, we all are wrong, all the time.
but why it's crashing on iOS Simulator ONLY but not everywhere? In following your explanation it should be crashing everywhere but it's not.
I believe I've already answered this. Perhaps you should read my explanation again.
-
@bogong said in Inherited QGuiApplication object do not working on iOS Simulator. Why?:
@kshegunov I mean if I am wrong - OK, but why it's crashing on iOS Simulator ONLY but not everywhere? In following your explanation it should be crashing everywhere but it's not.
That's an example of "undefined behaviour".
-
@kshegunov said in Inherited QGuiApplication object do not working on iOS Simulator. Why?:
I believe I've already answered this.
Sure, write an answer without explanation based on difference between Qt sources for different platform. And the problem is in QCoreApplication and how constructor calling from inherited class and possible in moc. Found cause of it by my own in Qt Sources. Issue closed.