QTimer is strange...



  • 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


  • Moderators

    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)?



  • [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 ... ?.


  • Moderators

    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)?



  • 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(


  • Moderators

    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.



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


  • Moderators

    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?



  • 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 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.


  • Moderators

    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.



  • 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]


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.