Results 1 to 10 of 10

Thread: QTimer and modeless dialog

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2011
    Posts
    15
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QTimer and modeless dialog

    Hi,

    I was faced with a very strange behavior. Not critical as I can do it other way but I would like to know why it happens.
    I have a qt designer class that I use as a modeless dialog In a mainwindow application.

    If i defined in my mainwindow.h a pointer to a QTimer variable my application always gives segfault at the call of the modeless dialog show(), regardless i do not even use or mention my QTimer pointer anywhere else in the program. Any no modeless dialogs work just fine.
    For my application to work I only need to comment the Qtimer *timer declaration in mainwindow.h

    I have no problem if i just define the timer in any of the mainwindow functions in mainwindow.cpp, and that's why this problem is not critical, but for me, at least, is very strange. It took me a large amount of hours to discovered that the segfault was due to the fact that I had a QTimer pointer defined in mainwindow.h as I couldn't spot any relation with that declaration, not even used anywhere else, and the modeless dialog.

    kind regards,

  2. #2
    Join Date
    May 2011
    Posts
    239
    Thanks
    4
    Thanked 35 Times in 35 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Symbian S60

    Default Re: QTimer and modeless dialog

    I would suggest that this happens because of either
    1) A corrupted build - try a clean and rebuild

    2) A compiler or linker bug

    3) Some other hidden bug is the real culprit; this piece of code just is a catalyst

    ...Of course, you should not have unused variables in your code... Perhaps the problem would go away if you used the variable.

  3. #3
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTimer and modeless dialog

    having an uninitialised pointer anywhere doesn't cause a seg fault inherently. I would suggest you still have a problem somewhere
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  4. #4
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QTimer and modeless dialog

    To say what the problem is, we should be able to see your code.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  5. #5
    Join Date
    Jul 2011
    Posts
    15
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QTimer and modeless dialog

    Quote Originally Posted by high_flyer View Post
    To say what the problem is, we should be able to see your code.
    I understand that. However it is a huge amount of code. I'm going to try to replicate the problem with a small ad-hoc application as I'm really worried about having an hidden bug completely unrelated. I'm assembling an application to be used by many co-workers in academic and scientific environment and it is really big.

    If I'm able to replicate the problem with a smaller code sample I'll post it again.

    Many thanks.

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QTimer and modeless dialog

    Sometimes it is enough to run your program with a debugger and post the backtrace of the crash. Just be sure to build the application in debug mode.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #7
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QTimer and modeless dialog

    a full clean and a rebuild might also help.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

Similar Threads

  1. modeless dialog in qt dll loaded in existing non qt app
    By elizabeth.h1 in forum Qt Programming
    Replies: 2
    Last Post: 28th July 2009, 12:49
  2. How to delete modeless dialog?
    By rajesh in forum Qt Programming
    Replies: 15
    Last Post: 16th June 2009, 12:19
  3. Modeless dialog disappearing
    By Raccoon29 in forum Qt Programming
    Replies: 4
    Last Post: 15th September 2007, 11:38
  4. modeless dialog closed signal?
    By gfunk in forum Qt Programming
    Replies: 2
    Last Post: 5th January 2007, 00:40
  5. modeless dialog
    By mhoover in forum Newbie
    Replies: 2
    Last Post: 23rd March 2006, 22:56

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.