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. How to correctly unload QApplication in a DLL?
Forum Updated to NodeBB v4.3 + New Features

How to correctly unload QApplication in a DLL?

Scheduled Pinned Locked Moved General and Desktop
21 Posts 3 Posters 8.4k Views 1 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.
  • M Offline
    M Offline
    maisoui
    wrote on last edited by
    #10

    I do this dummy code just to reproduce the issue. I know that myObject variable and variant are unused, but Qt crash the second time I reload the module.

    Once again, I guess the issue is coming from new structure (Qt5) of QMetaType and QVariant. I need to be able to unregister custom types or completely unload Qt libraries.

    1 Reply Last reply
    0
    • M Offline
      M Offline
      maisoui
      wrote on last edited by
      #11

      Yes, qApp can be NULL (from documentation: Returns a pointer to the application's QCoreApplication (or QApplication) instance. If no instance has been allocated, null is returned). But don't focus on that, If I change the code like this, problem is the same.
      @int argc = 0;
      myApplication = new QApplication(argc, NULL);

      ...

      delete myApplication;@

      1 Reply Last reply
      0
      • A Offline
        A Offline
        AlterX
        wrote on last edited by
        #12

        I don't think this is your problem...you are just setting a normal variable (QVariant) with another variable (MyObject)...problem is on qApp stuff.
        Can you check if second time a new QApplication is created again?

        Qt Ambassador
        Real-time cooperative teams: http://www.softairrealfight.net
        Free Real-time network platform sdk: https://github.com/AlterX76/Solomon

        https://codereview.qt-project.org/...

        1 Reply Last reply
        0
        • M Offline
          M Offline
          maisoui
          wrote on last edited by
          #13

          Checked. The second time a new QApplication is created too.

          1 Reply Last reply
          0
          • sierdzioS Offline
            sierdzioS Offline
            sierdzio
            Moderators
            wrote on last edited by
            #14

            I think you would get better answers on the interest mailing list. People fluent in QtCore code are likely to know the cause of your problem.

            (Z(:^

            1 Reply Last reply
            0
            • A Offline
              A Offline
              AlterX
              wrote on last edited by
              #15

              Anyway scenario is very complex since you are using a static object in process with another application (autocad) and managing a QApplication using qApp that can have different scope and logic behind.
              Can you tell me why are you using QApplication and if you remove those instructions if it is working

              Qt Ambassador
              Real-time cooperative teams: http://www.softairrealfight.net
              Free Real-time network platform sdk: https://github.com/AlterX76/Solomon

              https://codereview.qt-project.org/...

              1 Reply Last reply
              0
              • M Offline
                M Offline
                maisoui
                wrote on last edited by
                #16

                As with any Qt application, I need to create a valid QApplication. I'm surprised by your question.

                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  AlterX
                  wrote on last edited by
                  #17

                  I don't understand...you are creating a plugin for Autocad if you don't need gui why are you using Qt?
                  and again I don't think this is the correct approch to check qApp and create an anonymous QApplication without an explicit reference

                  Qt Ambassador
                  Real-time cooperative teams: http://www.softairrealfight.net
                  Free Real-time network platform sdk: https://github.com/AlterX76/Solomon

                  https://codereview.qt-project.org/...

                  1 Reply Last reply
                  0
                  • sierdzioS Offline
                    sierdzioS Offline
                    sierdzio
                    Moderators
                    wrote on last edited by
                    #18

                    AlterX QObject class requires a valid QCoreApplication instance to work properly.

                    (Z(:^

                    1 Reply Last reply
                    0
                    • M Offline
                      M Offline
                      maisoui
                      wrote on last edited by
                      #19

                      Yes, and I need GUI. I do a little condensed code just to reproduce the issue. Of course, this is not my whole application. It's just a "debug" example.

                      1 Reply Last reply
                      0
                      • A Offline
                        A Offline
                        AlterX
                        wrote on last edited by
                        #20

                        Ok, so due to this problem can be related to in process plugin, it is very hard to help you since we don't know how to reproduce this on our own. Maybe you can try to not unload the entire plugin and reload it, and have a only one instance of QApplication created when you load plugin? Can you do this?

                        Qt Ambassador
                        Real-time cooperative teams: http://www.softairrealfight.net
                        Free Real-time network platform sdk: https://github.com/AlterX76/Solomon

                        https://codereview.qt-project.org/...

                        1 Reply Last reply
                        0
                        • A Offline
                          A Offline
                          AlterX
                          wrote on last edited by
                          #21

                          [quote author="sierdzio" date="1417515370"]AlterX QObject class requires a valid QCoreApplication instance to work properly.[/quote]

                          Yes I know of course, but since he spoke about just an example I was thinking that original code was not using Qt and that this was just a curious question for him

                          Qt Ambassador
                          Real-time cooperative teams: http://www.softairrealfight.net
                          Free Real-time network platform sdk: https://github.com/AlterX76/Solomon

                          https://codereview.qt-project.org/...

                          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