Results 1 to 5 of 5

Thread: crash at QList<MyControls *> handling

  1. #1
    Join Date
    Oct 2009
    Posts
    90
    Thanks
    4
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default crash at QList<MyControls *> handling

    Hello again,

    i have encountered another crash at

    ========================================
    //header
    struct MyControls
    {
    QComboBox * my_combobox;
    QCheckBox * my_checkbox;
    };

    private:
    QList<MyControls *> my_control_list;

    //cpp
    MyControls mc[8];
    mc[0].my_combobox = ui->comboBox1;
    ...
    mc[7].my_combobox = ui->comboBox8;
    mc[0].my_checkbox = ui->checkBox1;
    ...
    mc[7].my_checkbox = ui->checkBox8;
    my_control_list.clear();
    my_control_list<<&mc[0]<<&mc[1]<<&mc[2]<<&mc[3]<<&mc[4]<<&mc[5]<<&mc[6]<<&mc[7];

    if(ui->checkBox1->isChecked()) return 1;
    if (! my_control_list.at(0)->my_checkbox->isChecked()) //<- crash
    return 0;

    ========================================

    regards
    navid

  2. #2
    Join Date
    Apr 2009
    Location
    Valencia (Spain)
    Posts
    245
    Thanks
    38
    Thanked 19 Times in 19 Posts
    Qt products
    Qt4
    Platforms
    Symbian S60

    Default Re: crash at QList<MyControls *> handling

    as I wrote you in the other post, use QList::insert

  3. #3
    Join Date
    Oct 2009
    Posts
    90
    Thanks
    4
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: crash at QList<MyControls *> handling

    it was done:
    for (int i=0; i<8; i++) {mfc_labels_list.insert(i,&ml[i]);}

    but till receive crash with error:
    .exe exited with code -1073741819 //(0xC0000005)

    It looks like it is dereferencing a pointer that is invalid

    //

    also as a test
    qDebug("list count = %d", my_control_list.count()); //list count = 8
    if (! my_control_list.at(0)->my_checkbox->isChecked()) //<- crash

    if (! my_control_list.at(1)->my_checkbox->isChecked()) //<- dont crash !

    if (! my_control_list.at(2)->my_checkbox->isChecked()) //<- dont crash !

    if (! my_control_list.at(7)->my_checkbox->isChecked()) //<- crash

    if (! my_control_list.at(8)->my_checkbox->isChecked()) //<- crash

  4. #4
    Join Date
    Oct 2009
    Posts
    90
    Thanks
    4
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: crash at QList<MyControls *> handling

    for (int i=0; i<8; i++) {mfc_labels_list.insert(i,&mc[i]);}

  5. #5
    Join Date
    Oct 2009
    Posts
    90
    Thanks
    4
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: crash at QList<MyControls *> handling

    sorry

    for (int i=0; i<8; i++) {my_control_list.insert(i,&mc[i]);}

Similar Threads

  1. Crash: Heap corruption due to selectedRows()
    By Ankitha Varsha in forum Qt Programming
    Replies: 16
    Last Post: 1st October 2010, 00:55
  2. QString comparison gives wierd crash
    By supergillis in forum Qt Programming
    Replies: 0
    Last Post: 1st June 2009, 22:09
  3. Replies: 2
    Last Post: 13th August 2008, 17:46
  4. QTableWidget Crash in Destructor
    By mclark in forum Qt Programming
    Replies: 19
    Last Post: 25th July 2008, 14:44
  5. QTimer ->start(0) + OpenGL + resize/move window => crash
    By anthibug in forum Qt Programming
    Replies: 5
    Last Post: 8th July 2008, 11:01

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.