Results 1 to 3 of 3

Thread: Crash on connect

  1. #1

    Default Crash on connect

    Hi all,

    I have a crash on connect in constructor

    Qt Code:
    1. BuilderAppInstanceUI::BuilderAppInstanceUI(const Workflow &wf)
    2. :ObserverAdapter(wf)
    3. {
    4. connect(Datasets, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), Variables, SLOT(datasetChanged(QListWidgetItem*,QListWidgetItem*)));
    5. }
    To copy to clipboard, switch view to plain text mode 

    with
    Qt Code:
    1. Datasets
    To copy to clipboard, switch view to plain text mode 
    and
    Qt Code:
    1. Variables
    To copy to clipboard, switch view to plain text mode 
    two members of
    Qt Code:
    1. BuilderAppInstanceUI
    To copy to clipboard, switch view to plain text mode 
    :

    Qt Code:
    1. class BuilderAppInstanceUI : public QWidget
    2. , public ObserverAdapter
    3. {
    4. Q_OBJECT
    5.  
    6. public:
    7. BuilderAppInstanceUI(const Workflow &workflow);
    8. ~BuilderAppInstanceUI();
    9.  
    10. void retranslateUi(QWidget *Form);
    11. void setupUi(QWidget *Form);
    12.  
    13. QStackedWidget *stackedWidget;
    14.  
    15.  
    16. BuilderAppListWidget *Datasets;
    17. QTreeWidget *Variables;
    18.  
    19. private slots:
    20. void datasetChanged(QListWidgetItem* current, QListWidgetItem* previous);
    21.  
    22. };
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. BuilderAppListWidget
    To copy to clipboard, switch view to plain text mode 
    inherits from
    Qt Code:
    To copy to clipboard, switch view to plain text mode 
    and as such can emit this signal
    Qt Code:
    1. SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*))
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. class BuilderAppListWidget : public QListWidget
    2. {
    3. Q_OBJECT
    4.  
    5. public:
    6. BuilderAppListWidget (QWidget* qwdgt = nullptr);
    7. ~BuilderAppListWidget (){};
    8.  
    9. void dragEnterEvent( QDragEnterEvent * event ) ;
    10. void dragMoveEvent( QDragMoveEvent * event ) ;
    11. void dropEvent( QDropEvent * event );
    12. void keyReleaseEvent( QKeyEvent * event ) final ;
    13.  
    14. private:
    15. BuilderAppInstanceUI* m_instance ;
    16.  
    17. };
    To copy to clipboard, switch view to plain text mode 

    Should I declare explicitly
    Qt Code:
    1. currentItemChanged
    To copy to clipboard, switch view to plain text mode 
    in body for
    Qt Code:
    1. BuilderAppListWidget
    To copy to clipboard, switch view to plain text mode 
    class ? If not, where does problem come from ?

    Regards

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: Crash on connect

    datasetChanged is a slot of BuilderAppInstanceUI (not Variables), the connect should look like
    Qt Code:
    1. connect(Datasets, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), this, SLOT(datasetChanged(QListWidgetItem*,QListWidgetItem*)));
    To copy to clipboard, switch view to plain text mode 
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  3. #3
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    4,718
    Thanks
    259
    Thanked 759 Times in 749 Posts
    Qt products
    Qt5
    Platforms
    Windows Android

    Default Re: Crash on connect

    datasetChanged is a slot of BuilderAppInstanceUI (not Variables), the connect should look like
    This wouldn't cause a crash, Qt would simply complain that the slot didn't exist.

    However, if the code posted for the BuilderAppInstanceUI constructor is the whole thing, then the "Datasets" and "Variables" members have not been initialized prior to the connect() so they point to random locations in memory, not to actual instances of the widgets they represent. This would most certainly cause the crash as Qt attempts to resolve the meta-objects in the connect() method's execution.

Similar Threads

  1. Replies: 2
    Last Post: 9th May 2011, 11:38
  2. crash at connect
    By Arifa in forum Qt Programming
    Replies: 0
    Last Post: 5th August 2010, 13:09
  3. Crash gracefully? No crash!
    By lni in forum Qt Programming
    Replies: 0
    Last Post: 7th July 2010, 04:59
  4. Replies: 16
    Last Post: 16th February 2010, 14:17
  5. Replies: 4
    Last Post: 10th November 2006, 16:38

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.