Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Inherited QGuiApplication object do not working on iOS Simulator. Why?

Inherited QGuiApplication object do not working on iOS Simulator. Why?

Scheduled Pinned Locked Moved Solved Mobile and Embedded
21 Posts 4 Posters 3.6k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    bogong
    wrote on last edited by bogong
    #9

    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:

    Screenshot 2019-10-03 at 01.16.52.png
    Screenshot 2019-10-03 at 01.17.27.png

    Why it might be only in iOS simulator? Every other platform working perfectly.

    1 Reply Last reply
    0
    • B bogong

      Hello all!
      Just got strange thing. The very simple class inherited from QGuiApplication do not working on iOS Simulator only. When I run it on Simulator it's starting and closing. Without any error message. When on iOS device everything fine. The same for desktop and Android - everything OK. The message that I see in iOS Simulator:

      18:06:47: Starting remote process.
      QML debugging is enabled. Only use this in a safe environment.
      18:06:49: Run ended.
      

      Nothing more than it.

      The class is very simple:

      • class CustomGuiApplication.cpp
      CustomGuiApplication::CustomGuiApplication(int inCounter,char *inArguments[]) : QGuiApplication(inCounter,inArguments) {}
      
      CustomGuiApplication::~CustomGuiApplication(void) {}
      
      • header CustomGuiApplication.h
      CustomGuiApplication : public QGuiApplication {
      
      	public:
      
      		explicit CustomGuiApplication(int inCounter,char *inArguments[]);
      		virtual ~CustomGuiApplication(void);
      };
      

      When I am using pure QGuiApplication all is OK. It's happening only if I am inheriting class and only on Simulator.
      Is it bug???

      kshegunovK Offline
      kshegunovK Offline
      kshegunov
      Moderators
      wrote on last edited by
      #10

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

      Read and abide by the Qt Code of Conduct

      B 1 Reply Last reply
      0
      • kshegunovK kshegunov

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

        B Offline
        B Offline
        bogong
        wrote on last edited by bogong
        #11

        @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???

        kshegunovK 1 Reply Last reply
        0
        • B bogong

          @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???

          kshegunovK Offline
          kshegunovK Offline
          kshegunov
          Moderators
          wrote on last edited by
          #12

          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

          Read and abide by the Qt Code of Conduct

          B 1 Reply Last reply
          0
          • kshegunovK kshegunov

            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

            B Offline
            B Offline
            bogong
            wrote on last edited by bogong
            #13

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

            kshegunovK 1 Reply Last reply
            0
            • B bogong

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

              kshegunovK Offline
              kshegunovK Offline
              kshegunov
              Moderators
              wrote on last edited by
              #14

              @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 from int.

              Read and abide by the Qt Code of Conduct

              B 1 Reply Last reply
              1
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #15

                One important thing, your constructor signature is wrong. See here, it's a reference to an int not an int for argc.

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                0
                • kshegunovK kshegunov

                  @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 from int.

                  B Offline
                  B Offline
                  bogong
                  wrote on last edited by bogong
                  #16

                  @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?

                  kshegunovK 1 Reply Last reply
                  0
                  • B bogong

                    @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?

                    kshegunovK Offline
                    kshegunovK Offline
                    kshegunov
                    Moderators
                    wrote on last edited by kshegunov
                    #17

                    @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 touches global1 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

                    Read and abide by the Qt Code of Conduct

                    B 1 Reply Last reply
                    2
                    • kshegunovK kshegunov

                      @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 touches global1 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

                      B Offline
                      B Offline
                      bogong
                      wrote on last edited by bogong
                      #18

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

                      kshegunovK SGaistS 2 Replies Last reply
                      0
                      • B bogong

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

                        kshegunovK Offline
                        kshegunovK Offline
                        kshegunov
                        Moderators
                        wrote on last edited by
                        #19

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

                        Read and abide by the Qt Code of Conduct

                        B 1 Reply Last reply
                        0
                        • B bogong

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

                          SGaistS Offline
                          SGaistS Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on last edited by
                          #20

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

                          Interested in AI ? www.idiap.ch
                          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                          1 Reply Last reply
                          1
                          • kshegunovK kshegunov

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

                            B Offline
                            B Offline
                            bogong
                            wrote on last edited by bogong
                            #21

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

                            1 Reply Last reply
                            0

                            • Login

                            • Login or register to search.
                            • First post
                              Last post
                            0
                            • Categories
                            • Recent
                            • Tags
                            • Popular
                            • Users
                            • Groups
                            • Search
                            • Get Qt Extensions
                            • Unsolved