Results 1 to 8 of 8

Thread: Program crash when a signal is emitted

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Oct 2008
    Location
    Brasil - São Paulo - Marília
    Posts
    28
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    3

    Default Program crash when a signal is emitted

    I have the following class definition:
    Qt Code:
    1. #ifndef QMYSQLTABLE_H
    2. #define QMYSQLTABLE_H
    3.  
    4. #include <QObject>
    5. #include <QSqlQuery>
    6.  
    7. class QMysqlConnection;
    8.  
    9. class QMysqlTable: public QObject, protected QSqlQuery
    10. {
    11. Q_OBJECT
    12.  
    13. friend class QDataLineEdit;
    14.  
    15. public:
    16. QMysqlTable(const QString& table, const QMysqlConnection* connection,
    17. QObject* = 0);
    18.  
    19. bool exec(const QString& query);
    20. bool isValid(void) const;
    21.  
    22. public slots:
    23. bool first(void);
    24. bool previous(void);
    25. bool next(void);
    26. bool last(void);
    27. bool seek(int index, bool relative = false);
    28.  
    29. signals:
    30. void firstRecord(void);
    31. void previousRecord(void);
    32. void nextRecord(void);
    33. void lastRecord(void);
    34. void seekRecord(void);
    35.  
    36. private:
    37. const QMysqlConnection* _connection;
    38.  
    39. const QString& _table;
    40. };
    41.  
    42. #endif // QMYSQLTABLE_H
    To copy to clipboard, switch view to plain text mode 

    and the implementation part the function next() is:
    Qt Code:
    1. bool QMysqlTable::next(void)
    2. {
    3. if (_connection->isValid()) {
    4. emit nextRecord();
    5.  
    6. return QSqlQuery::next();
    7. }
    8.  
    9. return false;
    10. }
    To copy to clipboard, switch view to plain text mode 

    the code for the next() function only work if the nextRecord() signal is not emited. Otherwise the program crashes.

    What could have been causing this behavior?

    Thanks in advance.
    Last edited by croscato; 22nd November 2008 at 13:57.

Similar Threads

  1. Replies: 5
    Last Post: 27th April 2009, 23:29
  2. Replies: 2
    Last Post: 16th August 2007, 00:20
  3. creating treeWidgetItem using emitted signal from thread class
    By santosh.kumar in forum Qt Programming
    Replies: 1
    Last Post: 25th June 2007, 08:37
  4. Replies: 5
    Last Post: 9th March 2007, 12:51
  5. QT MySQL
    By sabeeshcs in forum Newbie
    Replies: 6
    Last Post: 12th January 2007, 04:19

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.