[Qt-interest] dereferencing a pointer that is invalid
navid navid
n_nnavid at yahoo.com
Wed Nov 4 18:51:56 CET 2009
Hello,
i have encountered 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();
for (int i=0; i<8; i++) {my_control_list.insert(i,&mc[i]);}
if(ui->checkBox1->isChecked()) return 1;
if (! my_control_list.at(0)->my_checkbox->isChecked()) //<- crash
return 0;
========================================
the crash error is
myapplication.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
regards
navid
More information about the Qt-interest-old
mailing list