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. QMessageBox closes application
QtWS25 Last Chance

QMessageBox closes application

Scheduled Pinned Locked Moved Unsolved General and Desktop
qpolygonconnectmousepressevent
35 Posts 7 Posters 7.1k Views
  • 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.
  • H Offline
    H Offline
    hobbyProgrammer
    wrote on 7 Nov 2019, 10:10 last edited by hobbyProgrammer 11 Aug 2019, 12:06
    #1
    This post is deleted!
    J O P 3 Replies Last reply 7 Nov 2019, 10:12
    0
    • C Offline
      C Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on 7 Nov 2019, 10:12 last edited by
      #2

      @hobbyProgrammer said in connect() keeps crashing:

      Do you guys have any idea what might causes the app to crash?

      Take a debugger and look at the backtrace where exactly it crashes. Since you only show the connect to showContextMenu() and not it's implementation and you say it's crashing inside showContextMenu() we can't help any further.

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

      1 Reply Last reply
      4
      • H hobbyProgrammer
        7 Nov 2019, 10:10

        This post is deleted!

        J Offline
        J Offline
        jsulm
        Lifetime Qt Champion
        wrote on 7 Nov 2019, 10:12 last edited by
        #3

        @hobbyProgrammer said in connect() keeps crashing:

        It fully walks through the slot(showContextMenu)

        So, your slot is crashing, not connect()? connect() just connects signals and slots.
        What does your slot do (show code)?
        Do you have stack trace?

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        2
        • H hobbyProgrammer
          7 Nov 2019, 10:10

          This post is deleted!

          O Offline
          O Offline
          ODБOï
          wrote on 7 Nov 2019, 10:18 last edited by
          #4

          hi
          @hobbyProgrammer said in connect() keeps crashing:

          connect

          most likely this will not solve the crash but its better to use New Signal Slot Syntax

           connect(this, &MyClass::customContextMenuRequested, this, &MyClass::showContextMenu); 
          
          1 Reply Last reply
          2
          • M Offline
            M Offline
            marcbf
            wrote on 7 Nov 2019, 10:27 last edited by
            #5

            As @jsulm said, it's probably your slot that crashes. The reason for that assumption is that you don't specify a connection type and the default is a Qt::AutoConnection which in turn means a Qt::DirectConnection. That means your slot is called as soon as it is triggered. Perhaps something isn't quite ready at that point? Try specifying Qt:QueuedConnection as the connection type and see if that helps.

            As @LeLev points out you may be better off using the new signal/slot syntax as long as there isn't any overloaded signal in place. If you keep using the old signal/slot syntax (perfectly valid) you may want to change the parameter type(s) to the pure non-qualified type in your connect statement (and only there). That is, instead of specifying const QPoint&, just specify QPoint. Also, if you have more than one parameter make sure that there's no space before or after the comma.

            1 Reply Last reply
            0
            • H Offline
              H Offline
              hobbyProgrammer
              wrote on 7 Nov 2019, 11:35 last edited by
              #6

              @LeLev said in connect() keeps crashing:

              connect(this, &MyClass::customContextMenuRequested, this, &MyClass::showContextMenu);

              I tried this, but it still doesn't come back from the showContextMenu. I inserted a qDebug() at the end of showContextMenu and that one does show up in the debugger, but the qDebug() i've put after the connect() doesn't show up in the debugger.

              J J 2 Replies Last reply 7 Nov 2019, 11:51
              0
              • H hobbyProgrammer
                7 Nov 2019, 11:35

                @LeLev said in connect() keeps crashing:

                connect(this, &MyClass::customContextMenuRequested, this, &MyClass::showContextMenu);

                I tried this, but it still doesn't come back from the showContextMenu. I inserted a qDebug() at the end of showContextMenu and that one does show up in the debugger, but the qDebug() i've put after the connect() doesn't show up in the debugger.

                J Offline
                J Offline
                JonB
                wrote on 7 Nov 2019, 11:51 last edited by
                #7

                @hobbyProgrammer
                There is something very odd here. If it genuinely does not execute the line after the connect() as you say, then (presumably) the connection would not be made so the slot would never be called and you would not see showContextMenu() being called. Have a look again at your code/debug output, use a debugger breakpoint, etc.

                1 Reply Last reply
                0
                • H hobbyProgrammer
                  7 Nov 2019, 11:35

                  @LeLev said in connect() keeps crashing:

                  connect(this, &MyClass::customContextMenuRequested, this, &MyClass::showContextMenu);

                  I tried this, but it still doesn't come back from the showContextMenu. I inserted a qDebug() at the end of showContextMenu and that one does show up in the debugger, but the qDebug() i've put after the connect() doesn't show up in the debugger.

                  J Offline
                  J Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on 7 Nov 2019, 12:03 last edited by jsulm 11 Jul 2019, 12:03
                  #8

                  @hobbyProgrammer Then please show showContextMenu code or a stack trace, else we can only guess...
                  The thing is: connect() does not call showContextMenu, it just connects the signal to the slot.

                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                  H 1 Reply Last reply 7 Nov 2019, 12:08
                  0
                  • J jsulm
                    7 Nov 2019, 12:03

                    @hobbyProgrammer Then please show showContextMenu code or a stack trace, else we can only guess...
                    The thing is: connect() does not call showContextMenu, it just connects the signal to the slot.

                    H Offline
                    H Offline
                    hobbyProgrammer
                    wrote on 7 Nov 2019, 12:08 last edited by
                    #9

                    @jsulm It seems to print the qDebug() line before executing the connect(). And the app closes in the qeventloop.cpp.

                        while (!d->exit.loadAcquire())
                            processEvents(flags | WaitForMoreEvents | EventLoopExec);
                    

                    I have no idea why it stops there.

                    1 Reply Last reply
                    0
                    • H Offline
                      H Offline
                      hobbyProgrammer
                      wrote on 7 Nov 2019, 12:25 last edited by
                      #10

                      @jsulm it also stops whenever I save a file. The saving part works perfectly, but afterwards it just closes down the app and it seems to be the same mystery as the showContextMenu.
                      I would like to think that it's the connect function, since they both use connect().
                      However I've connected about 20 actions like this and only 2 seems to close the app. I would expect them all to close down the app if it were the connect() function.

                      J 1 Reply Last reply 7 Nov 2019, 12:28
                      0
                      • H hobbyProgrammer
                        7 Nov 2019, 12:25

                        @jsulm it also stops whenever I save a file. The saving part works perfectly, but afterwards it just closes down the app and it seems to be the same mystery as the showContextMenu.
                        I would like to think that it's the connect function, since they both use connect().
                        However I've connected about 20 actions like this and only 2 seems to close the app. I would expect them all to close down the app if it were the connect() function.

                        J Offline
                        J Offline
                        jsulm
                        Lifetime Qt Champion
                        wrote on 7 Nov 2019, 12:28 last edited by
                        #11

                        @hobbyProgrammer As I said: connect() does not call the slots.
                        Why don't you simply use debugger to see where exactly it crashes?

                        https://forum.qt.io/topic/113070/qt-code-of-conduct

                        H 1 Reply Last reply 7 Nov 2019, 12:51
                        1
                        • J jsulm
                          7 Nov 2019, 12:28

                          @hobbyProgrammer As I said: connect() does not call the slots.
                          Why don't you simply use debugger to see where exactly it crashes?

                          H Offline
                          H Offline
                          hobbyProgrammer
                          wrote on 7 Nov 2019, 12:51 last edited by
                          #12

                          @jsulm As I said:
                          it closes/crashes in the qeventloop.cpp.

                              while (!d->exit.loadAcquire())
                                  processEvents(flags | WaitForMoreEvents | EventLoopExec);
                          

                          But I have no clue how to prevent this

                          J 1 Reply Last reply 7 Nov 2019, 12:53
                          0
                          • H hobbyProgrammer
                            7 Nov 2019, 12:51

                            @jsulm As I said:
                            it closes/crashes in the qeventloop.cpp.

                                while (!d->exit.loadAcquire())
                                    processEvents(flags | WaitForMoreEvents | EventLoopExec);
                            

                            But I have no clue how to prevent this

                            J Offline
                            J Offline
                            JonB
                            wrote on 7 Nov 2019, 12:53 last edited by
                            #13

                            @hobbyProgrammer
                            @jsulm will know better than I, but I wouldn't have thought connect() would even call processEvents()/the main event loop?

                            1 Reply Last reply
                            0
                            • H Offline
                              H Offline
                              hobbyProgrammer
                              wrote on 7 Nov 2019, 13:09 last edited by
                              #14

                              @jsulm @JonB Whenever I use the debugger I don't even get the showContexyMenu(), but when I don't open in debugger, I do get the contextMenu...

                              J 1 Reply Last reply 7 Nov 2019, 13:12
                              0
                              • H hobbyProgrammer
                                7 Nov 2019, 13:09

                                @jsulm @JonB Whenever I use the debugger I don't even get the showContexyMenu(), but when I don't open in debugger, I do get the contextMenu...

                                J Offline
                                J Offline
                                jsulm
                                Lifetime Qt Champion
                                wrote on 7 Nov 2019, 13:12 last edited by
                                #15

                                @hobbyProgrammer Does it crash if you do not connect the slot?
                                And it would be helpful if you would post the stack trace after crash.

                                https://forum.qt.io/topic/113070/qt-code-of-conduct

                                1 Reply Last reply
                                0
                                • C Offline
                                  C Offline
                                  Christian Ehrlicher
                                  Lifetime Qt Champion
                                  wrote on 7 Nov 2019, 13:12 last edited by
                                  #16

                                  @hobbyProgrammer said in connect() keeps crashing:

                                  Whenever I use the debugger I don't even get the showContexyMenu(),

                                  So what's the backtrace?

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

                                  1 Reply Last reply
                                  0
                                  • H Offline
                                    H Offline
                                    hobbyProgrammer
                                    wrote on 7 Nov 2019, 13:20 last edited by hobbyProgrammer 11 Jul 2019, 13:25
                                    #17

                                    @jsulm @Christian-Ehrlicher

                                    I'm not really familliar with the debugger... Does this provide the information you need?

                                    70cbc7e0-a83b-464b-85d0-16d232d1b7e2-image.png

                                    J 1 Reply Last reply 7 Nov 2019, 13:27
                                    0
                                    • H hobbyProgrammer
                                      7 Nov 2019, 13:20

                                      @jsulm @Christian-Ehrlicher

                                      I'm not really familliar with the debugger... Does this provide the information you need?

                                      70cbc7e0-a83b-464b-85d0-16d232d1b7e2-image.png

                                      J Offline
                                      J Offline
                                      jsulm
                                      Lifetime Qt Champion
                                      wrote on 7 Nov 2019, 13:27 last edited by
                                      #18

                                      @hobbyProgrammer If you post screen shots you should at least make sure the function signature on the bottom-right side are readable...

                                      https://forum.qt.io/topic/113070/qt-code-of-conduct

                                      H 1 Reply Last reply 7 Nov 2019, 13:30
                                      0
                                      • J jsulm
                                        7 Nov 2019, 13:27

                                        @hobbyProgrammer If you post screen shots you should at least make sure the function signature on the bottom-right side are readable...

                                        H Offline
                                        H Offline
                                        hobbyProgrammer
                                        wrote on 7 Nov 2019, 13:30 last edited by
                                        #19

                                        @jsulm
                                        is this better?
                                        06faa0a2-725e-4ea8-9468-885d660f9c68-image.png

                                        J 1 Reply Last reply 7 Nov 2019, 13:33
                                        0
                                        • H hobbyProgrammer
                                          7 Nov 2019, 13:30

                                          @jsulm
                                          is this better?
                                          06faa0a2-725e-4ea8-9468-885d660f9c68-image.png

                                          J Offline
                                          J Offline
                                          JonB
                                          wrote on 7 Nov 2019, 13:33 last edited by JonB 11 Jul 2019, 13:34
                                          #20

                                          @hobbyProgrammer
                                          It would be better if we could read the full function signatures at the bottom right, instead of left-truncated! Can't you drag the column resizer so we can see the full function name? You can make columns like Condition or Ignore much smaller.

                                          1 Reply Last reply
                                          0

                                          1/35

                                          7 Nov 2019, 10:10

                                          • Login

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