Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Called object is not of the correct type (class destructor may have already run) - what is it? o.o
Forum Updated to NodeBB v4.3 + New Features

Called object is not of the correct type (class destructor may have already run) - what is it? o.o

Scheduled Pinned Locked Moved Unsolved General and Desktop
qcombobox
20 Posts 11 Posters 3.9k Views 6 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.
  • D Dariusz
    24 Jun 2022, 14:33

    Hey

    The app works fine on windows, but on MAC its fun stuff... I keep getting this >

    Called object is not of the correct type (class destructor may have already run)
    When I set it on QComboBox->setIndex(1)

    I'm puzzled :/

    J Offline
    J Offline
    JonB
    wrote on 24 Jun 2022, 14:41 last edited by
    #2

    @Dariusz
    You have a (pointer) variable named QComboBox when the class is named QComboBox?

    My guess is this is a runtime error message when QComboBox does not point to a still-live QComboBox?

    1 Reply Last reply
    2
    • M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 24 Jun 2022, 14:43 last edited by
      #3

      @Dariusz said in Called object is not of the correct type (class destructor may have already run) - what is it? o.o:

      Called object is not of the correct type (class destructor may have already run)

      please show the real actual code as QComboBox->setIndex(1) seems wrong due to the var name.

      D 1 Reply Last reply 24 Jun 2022, 15:33
      0
      • M mrjj
        24 Jun 2022, 14:43

        @Dariusz said in Called object is not of the correct type (class destructor may have already run) - what is it? o.o:

        Called object is not of the correct type (class destructor may have already run)

        please show the real actual code as QComboBox->setIndex(1) seems wrong due to the var name.

        D Offline
        D Offline
        Dariusz
        wrote on 24 Jun 2022, 15:33 last edited by Dariusz
        #4

        Hey
        @JonB Its definitely alive, it runs fine on windows, and when I debug it I can see item with valid data/etc. & its QComboBox
        @mrjj Sorry my bad! Its> setCurrentIndex.

        I've removed it now to "skip the crash" to test more and I crashed again on another thing totally. Mac... fun time.
        It feels like calling a slot on Qt item can cause explosion...
        Here is screnschot of comboBox trace log >
        Screenshot 2022-06-24 at 16.28.05.png

        I'm lost, trying to dig through it somehow.

        Ok I'm closer to answer...
        I cant do this >
        connect(mRange, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &icCurveWidget::pushUpdate);
        My "new" signals breaks I have to revert back to old(sender, SIGNAL() , this,SLOT()); :- (((( no idea why the new ones wont work for me:/

        This object is made by a dylib plugin that creates view, which is a static library imported to main app that imports dylib. I wonder if I need to add some kind of... export macros hmmmmmmmmm

        J M 2 Replies Last reply 24 Jun 2022, 16:17
        0
        • D Dariusz
          24 Jun 2022, 15:33

          Hey
          @JonB Its definitely alive, it runs fine on windows, and when I debug it I can see item with valid data/etc. & its QComboBox
          @mrjj Sorry my bad! Its> setCurrentIndex.

          I've removed it now to "skip the crash" to test more and I crashed again on another thing totally. Mac... fun time.
          It feels like calling a slot on Qt item can cause explosion...
          Here is screnschot of comboBox trace log >
          Screenshot 2022-06-24 at 16.28.05.png

          I'm lost, trying to dig through it somehow.

          Ok I'm closer to answer...
          I cant do this >
          connect(mRange, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &icCurveWidget::pushUpdate);
          My "new" signals breaks I have to revert back to old(sender, SIGNAL() , this,SLOT()); :- (((( no idea why the new ones wont work for me:/

          This object is made by a dylib plugin that creates view, which is a static library imported to main app that imports dylib. I wonder if I need to add some kind of... export macros hmmmmmmmmm

          J Offline
          J Offline
          JonB
          wrote on 24 Jun 2022, 16:17 last edited by
          #5

          @Dariusz
          In have no idea what you are trying to achieve. But if you static_cast<> and that is wrong (not of the type you tell the compiler it is) then could cause the kind of error you reported. Why are you using any kind of static_cast?

          1 Reply Last reply
          2
          • D Dariusz
            24 Jun 2022, 15:33

            Hey
            @JonB Its definitely alive, it runs fine on windows, and when I debug it I can see item with valid data/etc. & its QComboBox
            @mrjj Sorry my bad! Its> setCurrentIndex.

            I've removed it now to "skip the crash" to test more and I crashed again on another thing totally. Mac... fun time.
            It feels like calling a slot on Qt item can cause explosion...
            Here is screnschot of comboBox trace log >
            Screenshot 2022-06-24 at 16.28.05.png

            I'm lost, trying to dig through it somehow.

            Ok I'm closer to answer...
            I cant do this >
            connect(mRange, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &icCurveWidget::pushUpdate);
            My "new" signals breaks I have to revert back to old(sender, SIGNAL() , this,SLOT()); :- (((( no idea why the new ones wont work for me:/

            This object is made by a dylib plugin that creates view, which is a static library imported to main app that imports dylib. I wonder if I need to add some kind of... export macros hmmmmmmmmm

            M Offline
            M Offline
            mchinand
            wrote on 24 Jun 2022, 16:30 last edited by
            #6

            Use qOverload instead of static_cast. See Selecting Overloaded Signals and Slots

            1 Reply Last reply
            4
            • D Offline
              D Offline
              Dariusz
              wrote on 24 Jun 2022, 17:16 last edited by
              #7

              Hey

              Yeah thats a crazy one overload, looking at data years old so uhh my bad!

              Fixing it sadly did not help, another signal/slots screams here >

              This crash > connect(addItem, &QAction::triggered, this, &icCGraphicsScene::addItemPoint);
              This works > connect(addItem, &QAction::triggered, this, [this]() { this->addItemPoint(); });
              Yes I know the "works" one is not good, but I simply cant connect normal signals on M1 mac. Maybe its ARM issue ?

              J K 2 Replies Last reply 24 Jun 2022, 17:36
              0
              • D Dariusz
                24 Jun 2022, 17:16

                Hey

                Yeah thats a crazy one overload, looking at data years old so uhh my bad!

                Fixing it sadly did not help, another signal/slots screams here >

                This crash > connect(addItem, &QAction::triggered, this, &icCGraphicsScene::addItemPoint);
                This works > connect(addItem, &QAction::triggered, this, [this]() { this->addItemPoint(); });
                Yes I know the "works" one is not good, but I simply cant connect normal signals on M1 mac. Maybe its ARM issue ?

                J Offline
                J Offline
                JonB
                wrote on 24 Jun 2022, 17:36 last edited by
                #8

                @Dariusz
                If somebody can help further they will surely want to know what version of Qt you are using and what kind of MacOS version?

                D 1 Reply Last reply 24 Jun 2022, 17:59
                0
                • J JonB
                  24 Jun 2022, 17:36

                  @Dariusz
                  If somebody can help further they will surely want to know what version of Qt you are using and what kind of MacOS version?

                  D Offline
                  D Offline
                  Dariusz
                  wrote on 24 Jun 2022, 17:59 last edited by
                  #9

                  @JonB 6.3.0, MacOS Monterey 12.4 (21F79). Mac M1 Mini.
                  I've had this problem for year + now I think.

                  Cant signal slot 50% of my connections for some reason.

                  Just did not know that this error is this. I usually fix it via either old SIGNAL(), SLOT() connection or lambda :/

                  J 1 Reply Last reply 24 Jun 2022, 18:01
                  0
                  • D Dariusz
                    24 Jun 2022, 17:59

                    @JonB 6.3.0, MacOS Monterey 12.4 (21F79). Mac M1 Mini.
                    I've had this problem for year + now I think.

                    Cant signal slot 50% of my connections for some reason.

                    Just did not know that this error is this. I usually fix it via either old SIGNAL(), SLOT() connection or lambda :/

                    J Offline
                    J Offline
                    JonB
                    wrote on 24 Jun 2022, 18:01 last edited by
                    #10

                    @Dariusz
                    ...and then someone will ask whether you can produce any one minimal example which shows this problem for you, so they can actually try it...? :)

                    D 1 Reply Last reply 24 Jun 2022, 18:09
                    0
                    • J JonB
                      24 Jun 2022, 18:01

                      @Dariusz
                      ...and then someone will ask whether you can produce any one minimal example which shows this problem for you, so they can actually try it...? :)

                      D Offline
                      D Offline
                      Dariusz
                      wrote on 24 Jun 2022, 18:09 last edited by
                      #11

                      @JonB Its been on my todo list for a year :- )

                      I will eventually make it...

                      I'm sorry, its topic repeat, I know the answer is null till I post a git project that can reproduce it, its just lots of work to do it :D
                      I just didn't realise it was signal error again, sigh.
                      Sorri, & thank you for help <3
                      Regards
                      Dariusz

                      1 Reply Last reply
                      0
                      • D Dariusz
                        24 Jun 2022, 17:16

                        Hey

                        Yeah thats a crazy one overload, looking at data years old so uhh my bad!

                        Fixing it sadly did not help, another signal/slots screams here >

                        This crash > connect(addItem, &QAction::triggered, this, &icCGraphicsScene::addItemPoint);
                        This works > connect(addItem, &QAction::triggered, this, [this]() { this->addItemPoint(); });
                        Yes I know the "works" one is not good, but I simply cant connect normal signals on M1 mac. Maybe its ARM issue ?

                        K Offline
                        K Offline
                        KroMignon
                        wrote on 26 Jun 2022, 14:06 last edited by
                        #12

                        @Dariusz said in Called object is not of the correct type (class destructor may have already run) - what is it? o.o:

                        Hey
                        Yeah thats a crazy one overload, looking at data years old so uhh my bad!
                        Fixing it sadly did not help, another signal/slots screams here >
                        This crash > connect(addItem, &QAction::triggered, this, &icCGraphicsScene::addItemPoint);
                        This works > connect(addItem, &QAction::triggered, this, this { this->addItemPoint(); });
                        Yes I know the "works" one is not good, but I simply cant connect normal signals on M1 mac. Maybe its ARM issue ?

                        DISCLAIMER: I have never developed Qt application for Mac (or used a Mac).

                        My guess is that you have an issue on instance class life cycle.
                        When creating a lambda function, the captured variables are copied.

                        But this is just a fealling...

                        It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

                        D 1 Reply Last reply 24 Apr 2023, 21:33
                        0
                        • K KroMignon
                          26 Jun 2022, 14:06

                          @Dariusz said in Called object is not of the correct type (class destructor may have already run) - what is it? o.o:

                          Hey
                          Yeah thats a crazy one overload, looking at data years old so uhh my bad!
                          Fixing it sadly did not help, another signal/slots screams here >
                          This crash > connect(addItem, &QAction::triggered, this, &icCGraphicsScene::addItemPoint);
                          This works > connect(addItem, &QAction::triggered, this, this { this->addItemPoint(); });
                          Yes I know the "works" one is not good, but I simply cant connect normal signals on M1 mac. Maybe its ARM issue ?

                          DISCLAIMER: I have never developed Qt application for Mac (or used a Mac).

                          My guess is that you have an issue on instance class life cycle.
                          When creating a lambda function, the captured variables are copied.

                          But this is just a fealling...

                          D Offline
                          D Offline
                          Dariusz
                          wrote on 24 Apr 2023, 21:33 last edited by Dariusz
                          #13

                          @KroMignon I'm back to this hell of an issue :- D

                          Nope live-time is not the problem. Both objects are alive.

                          Seems like he can't resolve signals/names somehow properly.
                          Perhaps its my namespace.
                          Or ARM
                          Or there is some build flag I'm missing.

                          I just did big update to my UI library, everything works on Windows, but I go to MAC and he ignores all signal/slots connections, or most of them. I'm linking against static .a library creating dylib one and loading it in my app at runtime.

                          At some point Qt for mac fails in my crazy build :/

                          I have to redo all my signals now from signal>signal or signal>slot connections to signal>lambda ;/////

                          qOverload sadly does not work either.

                          QLineEdit will just crash (or my customLineEdit) and QCheckBox will just "not work".

                          im on 6.5 Qt btw. moved from 6.1 I think.

                          M 1 Reply Last reply 24 Jul 2023, 07:05
                          0
                          • D Dariusz
                            24 Apr 2023, 21:33

                            @KroMignon I'm back to this hell of an issue :- D

                            Nope live-time is not the problem. Both objects are alive.

                            Seems like he can't resolve signals/names somehow properly.
                            Perhaps its my namespace.
                            Or ARM
                            Or there is some build flag I'm missing.

                            I just did big update to my UI library, everything works on Windows, but I go to MAC and he ignores all signal/slots connections, or most of them. I'm linking against static .a library creating dylib one and loading it in my app at runtime.

                            At some point Qt for mac fails in my crazy build :/

                            I have to redo all my signals now from signal>signal or signal>slot connections to signal>lambda ;/////

                            qOverload sadly does not work either.

                            QLineEdit will just crash (or my customLineEdit) and QCheckBox will just "not work".

                            im on 6.5 Qt btw. moved from 6.1 I think.

                            M Offline
                            M Offline
                            Marcus Tillmanns
                            wrote on 24 Jul 2023, 07:05 last edited by
                            #14

                            @Dariusz
                            I'm having the same issue (also M1 mac, haven't tried on other platforms yet). The problem seems to be that inside Qt code, the call to call dynamic_cast<>() fails for my object, even though it should work. The target class that it cannot dynamic_cast to is defined in a static library. When I change it to a dynamic library instead, everything works fine.

                            Did you have any more luck in the mean time?

                            J.HilkJ SGaistS 2 Replies Last reply 24 Jul 2023, 07:19
                            1
                            • M Marcus Tillmanns
                              24 Jul 2023, 07:05

                              @Dariusz
                              I'm having the same issue (also M1 mac, haven't tried on other platforms yet). The problem seems to be that inside Qt code, the call to call dynamic_cast<>() fails for my object, even though it should work. The target class that it cannot dynamic_cast to is defined in a static library. When I change it to a dynamic library instead, everything works fine.

                              Did you have any more luck in the mean time?

                              J.HilkJ Offline
                              J.HilkJ Offline
                              J.Hilk
                              Moderators
                              wrote on 24 Jul 2023, 07:19 last edited by
                              #15

                              @Marcus-Tillmanns interesting, I'm personally using a mix of static and dynamic libs (all qt based) on Mac and everything works just fine.

                              But I'm also using 5.15 and not Qt6


                              Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                              Q: What's that?
                              A: It's blue light.
                              Q: What does it do?
                              A: It turns blue.

                              V 1 Reply Last reply 26 Mar 2024, 11:37
                              0
                              • M Marcus Tillmanns
                                24 Jul 2023, 07:05

                                @Dariusz
                                I'm having the same issue (also M1 mac, haven't tried on other platforms yet). The problem seems to be that inside Qt code, the call to call dynamic_cast<>() fails for my object, even though it should work. The target class that it cannot dynamic_cast to is defined in a static library. When I change it to a dynamic library instead, everything works fine.

                                Did you have any more luck in the mean time?

                                SGaistS Offline
                                SGaistS Offline
                                SGaist
                                Lifetime Qt Champion
                                wrote on 24 Jul 2023, 20:13 last edited by
                                #16

                                @Marcus-Tillmanns hi,

                                Any chances you are using plugins in your application ?

                                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
                                • danttiD Offline
                                  danttiD Offline
                                  dantti
                                  wrote on 14 Sept 2023, 23:18 last edited by
                                  #17

                                  This is not related to ARM/Mac whatever, nor will happen before Qt 6.3.

                                  The issue is that in 6.3 there's now an assert that checks if the receiver object and method "match", it works with lambdas as it's either incomplete or impossible to check because lambdas aren't part of the receiver type.

                                  This happened to a code I replaced the old syntax and the issue was that some Parent class while destroying children of of them, had a signal being emitted on destructor, that called some functions and emitted back to the half destructed Parent hitting the assert.

                                  What I did was to queue one the signals to allow the destructor to finish.

                                  1 Reply Last reply
                                  0
                                  • J.HilkJ J.Hilk
                                    24 Jul 2023, 07:19

                                    @Marcus-Tillmanns interesting, I'm personally using a mix of static and dynamic libs (all qt based) on Mac and everything works just fine.

                                    But I'm also using 5.15 and not Qt6

                                    V Offline
                                    V Offline
                                    Vinny_Jones91
                                    wrote on 26 Mar 2024, 11:37 last edited by Vinny_Jones91
                                    #18

                                    @SGAIST hello.

                                    I've encountered the same issue with Qt6.6.2 and yes, we're using plugins in our macOS application.

                                    Looks like dymanic_cast fails to work correctly across dylib boundaries.
                                    -flat_namespace compile option helps with dynamic_cast itself (and so, fixed the mentioned assert), but causes other issues for us.

                                    If you could share any thoughts on how this may be fixed, that would be much appreciated.

                                    SGaistS 1 Reply Last reply 26 Mar 2024, 20:07
                                    0
                                    • V Vinny_Jones91
                                      26 Mar 2024, 11:37

                                      @SGAIST hello.

                                      I've encountered the same issue with Qt6.6.2 and yes, we're using plugins in our macOS application.

                                      Looks like dymanic_cast fails to work correctly across dylib boundaries.
                                      -flat_namespace compile option helps with dynamic_cast itself (and so, fixed the mentioned assert), but causes other issues for us.

                                      If you could share any thoughts on how this may be fixed, that would be much appreciated.

                                      SGaistS Offline
                                      SGaistS Offline
                                      SGaist
                                      Lifetime Qt Champion
                                      wrote on 26 Mar 2024, 20:07 last edited by
                                      #19

                                      @Vinny_Jones91 hi and welcome to devnet,

                                      Any chances you are using static libraries to build your plugins ?

                                      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
                                      • I Offline
                                        I Offline
                                        Icaro
                                        wrote on 13 Sept 2024, 09:12 last edited by Icaro
                                        #20

                                        I had a similar issue and @SGaist question actually helped me.
                                        My code was hitting the "called object is not the correct type class destructor..." assertion and I changed the library from static to dynamic and now it seems to work properly on MacOS.
                                        Not sure what the issue is or if it is a bug that is already solved in more recent versions (I am currently using Qt6.4.2) but I will go for the dynamic library solution for now so I can move forward.
                                        Thanks!

                                        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