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. QTimer is strange...

QTimer is strange...

Scheduled Pinned Locked Moved General and Desktop
12 Posts 3 Posters 4.0k 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.
  • F Offline
    F Offline
    Francknos
    wrote on last edited by
    #1

    Hi, I have something in my code which is incredible.

    My class
    @
    class MainWidget : public QWidget
    {
    Q_OBJECT

    enum{
        ERROR_API = 0,
        ERROR_DATABASE = 1
    };
    

    public:
    explicit MainWidget(QWidget *parent = 0);
    ~MainWidget();

    void initialisations();
    ...
    

    private:
    Ui::MainWidget *ui;
    ParamUSKey *paramKey;
    ApiUsb *apiUsb;
    QSqlDatabase *bd;
    //QTimer *timerPLOP;
    };
    @

    When I uncomment @QTimer *timerPLOP;@ My application crash at closing.
    Without doing anything with this timer ... any idea?

    thx

    1 Reply Last reply
    0
    • Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Maybe it's a corrupted build. Try cleaning and rebuilding.
      What steps did you take to investigate this? Have you used a debugger to see where exactly does it crash? What OS, compiler and Qt version are you on?
      The timer there might just accidentally trigger the problem, not cause it. It changes the size of your class for example. Have you tried to swap it for any other type to see if it keeps crashing? Do you have an include for the QTimer type in that header or cpp (using an incomplete type pointer in the source can cause random crashes)?

      1 Reply Last reply
      0
      • F Offline
        F Offline
        Francknos
        wrote on last edited by
        #3

        [quote author="Chris Kawa" date="1415632608"]Maybe it's a corrupted build. Try cleaning and rebuilding.[/quote]
        Already done ...

        [quote author="Chris Kawa" date="1415632608"]What OS, compiler and Qt version are you on?[/quote]
        Qt 3.0.0 frim : 5.2.0 on windows 7 and 8.1

        It's difficult for me to see where it's crash ... It's when I quit my application ...
        I put a debug point on my destructor but apparently my app crash before ... ?.

        1 Reply Last reply
        0
        • Chris KawaC Offline
          Chris KawaC Offline
          Chris Kawa
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Don't put a breakpoint. Let it crash and see the call stack.
          Do you know how to use a debugger for this(I'm not being a jerk, just asking)?

          1 Reply Last reply
          0
          • F Offline
            F Offline
            Francknos
            wrote on last edited by
            #5

            I'm not really good to use de debugger but I have a SEG FAULT ... and it's not rellay good ^^

            My debugger stop on this line
            @0x7704dfe4 <+0x01f8> cmpb $0x5,0x7(

            1 Reply Last reply
            0
            • Chris KawaC Offline
              Chris KawaC Offline
              Chris Kawa
              Lifetime Qt Champion
              wrote on last edited by
              #6

              That's an assembly line. It's like saying "look, 42". It tells us nothing ;)

              See this: "Viewing call stack trace":http://qt-project.org/doc/qtcreator-3.2/creator-debug-mode.html#viewing-call-stack-trace

              Run the app with debugger (F5 key). When it crashes it will break. Go to the Stack window and find the top-most function from your code. Click on it and it will get you to the line that causes the crash. Inspect whatever variables you have there. Check if pointers are not null etc. If you need to you can go up the call tree by clicking on the lower entries in the Stack window.

              1 Reply Last reply
              0
              • F Offline
                F Offline
                Francknos
                wrote on last edited by
                #7

                Thx, I'll do this but I have no function.
                "Debbug":https://www.dropbox.com/s/excaaexa83ngzup/Capture.JPG?dl=0

                1 Reply Last reply
                0
                • Chris KawaC Offline
                  Chris KawaC Offline
                  Chris Kawa
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  Then set a breakpoint somewhere early and step (F10/F11) until it crashes.

                  I can't help you much without seeing the whole code. Can you post it or pack a minimal reproducible example on some sharing platform?

                  1 Reply Last reply
                  0
                  • S Offline
                    S Offline
                    Sam
                    wrote on last edited by
                    #9

                    Do you have dependent modules in your session ? if yes then the dependent modules are always build fresh or you have few local and few published modules.

                    If you are getting a crash like @0×7704dfe4 <+0×01f8> cmpb $0×5,0×7(

                    it might be the binaries needs to be build/published again.

                    Regards
                    Sam

                    1 Reply Last reply
                    0
                    • F Offline
                      F Offline
                      Francknos
                      wrote on last edited by
                      #10

                      [quote author="Chris Kawa" date="1415706556"]Then set a breakpoint somewhere early and step (F10/F11) until it crashes.

                      I can't help you much without seeing the whole code. Can you post it or pack a minimal reproducible example on some sharing platform?[/quote]

                      I can't publish more... And anyway all code is on top.
                      If I uncomment QTimer *timer; My code crash at the close event.

                      [quote author="Sam" date="1415714262"]Do you have dependent modules in your session ? if yes then the dependent modules are always build fresh or you have few local and few published modules.

                      If you are getting a crash like @0×7704dfe4 <+0×01f8> cmpb $0×5,0×7(

                      it might be the binaries needs to be build/published again.

                      Regards
                      Sam

                      [/quote]

                      Yes I have several library in my code.

                      1 Reply Last reply
                      0
                      • Chris KawaC Offline
                        Chris KawaC Offline
                        Chris Kawa
                        Lifetime Qt Champion
                        wrote on last edited by
                        #11

                        The pointer itself is accidental. I mean it's 4 bytes (or whatever the size of pointer is on your platform) of data, not even an executable code. You don't even create an instance of QTimer, just an uninitialized pointer so it has nothing to do with that type. There is no way it can cause a crash by just being there. Unless you actually use it somehow in your code it just reveals some other problem in your app that might be unrelated.
                        I'd try to strip the app step by step to bare minimum, naked main() even and remove any dependent libraries one by one and see when it stops crashing. This would at least help you to locate the true cause.

                        1 Reply Last reply
                        0
                        • F Offline
                          F Offline
                          Francknos
                          wrote on last edited by
                          #12

                          Thanks for your help. I found the problem which are no relation with QTimer.
                          It was an instance with a dll (pointer not initialized)

                          thx for your help

                          [quote author="Chris Kawa" date="1415786692"] [/quote]

                          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