Results 1 to 4 of 4

Thread: Program Crashing because of Singal [need help!]

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Program Crashing because of Singal [need help!]

    Qt Code:
    1. //slots
    2. void QSS::fechar()
    3. {
    4. this->~QSplashScreen();
    5. emit fechou();
    6. }
    To copy to clipboard, switch view to plain text mode 
    You are destroying the QSplashScreen underpinning your derived QSS splash screen and then trying to use the object. It is hardly surprising this crashes. I don't know of any circumstance under which you would call a destructor directly.

    Take nix's advice including the Qt::WA_DeleteOnClose flag to avoid the resource leak you have at the moment (or put it on the stack). You are also leaking memory by allocating a QTimer on the heap, not setting a parent, and then discarding the pointer to it. No need to create a timer explicitly. Just use the QTimer::singleShot() static function.

  2. #2
    Join Date
    Oct 2011
    Posts
    9
    Thanks
    1

    Default Re: Program Crashing because of Singal [need help!]

    Thanks for the tip!

    Both advices where very good and it does just what is meant too.

    And sorry, I didn't know how to use code tag... I'll learn for next time.

    #THIS IS ME EDITING THIS POST. Searched and now its good to go with the CodeTag. Thanks!

    Qt Code:
    1. --QSS.h--
    2. #ifndef QSS_H
    3. #define QSS_H
    4. #include <QSplashScreen>
    5. #include <QTimer>
    6. #include <QWidget>
    7. #include <QObject>
    8. #include <QtGui>
    9.  
    10.  
    11. class QSS: public QSplashScreen {
    12.  
    13. Q_OBJECT
    14.  
    15. public:
    16. explicit QSS(QSplashScreen *parent = 0);
    17. void criarTimer();
    18.  
    19. public slots:
    20. void fechar();
    21.  
    22. signals:
    23. void fechou();
    24. };
    25.  
    26. #endif // QSS_H
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Crashing without debug mode- No crashing with gdb debugger
    By sujan.dasmahapatra in forum Qt Programming
    Replies: 1
    Last Post: 7th February 2011, 11:27
  2. Replies: 12
    Last Post: 9th January 2011, 13:51
  3. program crashing randomly code -1073741819
    By feraudyh in forum General Programming
    Replies: 6
    Last Post: 21st September 2010, 17:07
  4. Debugging singal-slot connections
    By gnik in forum Qt-based Software
    Replies: 0
    Last Post: 11th July 2009, 19:50
  5. singal send twice?
    By masoroso in forum Qt Programming
    Replies: 1
    Last Post: 12th April 2007, 13:47

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
  •  
Qt is a trademark of The Qt Company.