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. Why crash in QDialog::close()
Forum Updated to NodeBB v4.3 + New Features

Why crash in QDialog::close()

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 3 Posters 690 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.
  • T Offline
    T Offline
    Toocold
    wrote on last edited by
    #1
    void func()
    {
        QMetaObject::invokeMethod(qApp, [this]
            {
                pLoading->close();
                pLoading = NULL;
                pMainWindow->show();
            });
    }
    

    My Qcoreapplication was created and Run in a Secondary Thread. pLoading(QDialog) and pMainWindow also created and be used in the same thread as GUI Class.
    This func() above was called in the main thread, it performed well in my computer.
    But when I look into others' dumper, I find someone (2% people) crash when pLoading->close();( Qt5Widgets.dll!QWidgetPrivate::close_helper(QWidgetPrivate::CloseMode mode))

    What are the possible reasons.

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

      Hi,

      There's no check that pLoading is a valid pointer.

      Nothing in that code shows that it's is run in the correct thread therefore you might be just lucky that it runs 98% of the time.

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

      T 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        There's no check that pLoading is a valid pointer.

        Nothing in that code shows that it's is run in the correct thread therefore you might be just lucky that it runs 98% of the time.

        T Offline
        T Offline
        Toocold
        wrote on last edited by
        #3

        @SGaist Thanks for your reply.

            bRetCode = QMetaObject::invokeMethod(qApp, [this]
                {
                    pMainWindow = new KMainWindowNew(NULL);
                    pLoading = new KLoading(NULL);
                }, Qt::BlockingQueuedConnection);
        

        I think this code make sure pLoading is created in the correct thread, and it will exec() by the same way.
        Maybe pLoading was closed by people, so no check that pLoading make the application crashed?

        1 Reply Last reply
        0
        • Christian EhrlicherC Offline
          Christian EhrlicherC Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @Toocold said in Why crash in QDialog::close():

          so no check that pLoading make the application crashed?

          Use QPointer<> and check for != nullptr before calling close()

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          T 1 Reply Last reply
          1
          • Christian EhrlicherC Christian Ehrlicher

            @Toocold said in Why crash in QDialog::close():

            so no check that pLoading make the application crashed?

            Use QPointer<> and check for != nullptr before calling close()

            T Offline
            T Offline
            Toocold
            wrote on last edited by
            #5

            @Christian-Ehrlicher said in Why crash in QDialog::close():

            @Toocold said in Why crash in QDialog::close():

            so no check that pLoading make the application crashed?

            Use QPointer<> and check for != nullptr before calling close()

            okay

            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