mclark
9th October 2006, 22:11
When my function containing a QList<QTableWidgetSelectionRange> goes out of scope I get a crash in ~QList(). The call to this function is a response to a button click in a QDialog.
My intent is to find all rows with at least one cell selected and store a string from a cell in that row.
void Detect::on_Btn_clicked( void )
{
QList<QTableWidgetSelectionRange> list = ui.table->selectedRanges();
QStringList sList;
for ( int i = 0; i < list.count(); i++ )
{
if ( !sList.contains( ui.table->item( list[i].topRow(), COL2_IP )->text() ) )
sList.append( ui.table->item( list[i].topRow(), COL2_IP )->text() );
}
accept();
}
Even stripping the function to just:
void Detect::on_Btn_clicked( void )
{
QList<QTableWidgetSelectionRange> list = ui.table->selectedRanges();
accept();
}
still causes the crash.
My debugger lists a stack trace of:
msvcr71d.dll!operator delete(void* pUserData=non-zero)
QTableWidgetSelectionRange::`scalar deleting destructor'()
QList<QTableWidgetSelectionRange>::node_destructQList<QTableWidgetSelectionRange>::Node*from=non-zero)
QList<QTableWidgetSelectionRange>::free(QListData::Data*data=non-zero)
QList<QTableWidgetSelectionRange>::~QList<QTableWidgetSelectionRange>()
Detect::on_Btn_clicked()
All data in the stack trace is non-zero so I don't think I've got a NULL pointer causing the problem. Is there some maintainence that must be done to the contents of the QList before the function ends?
My intent is to find all rows with at least one cell selected and store a string from a cell in that row.
void Detect::on_Btn_clicked( void )
{
QList<QTableWidgetSelectionRange> list = ui.table->selectedRanges();
QStringList sList;
for ( int i = 0; i < list.count(); i++ )
{
if ( !sList.contains( ui.table->item( list[i].topRow(), COL2_IP )->text() ) )
sList.append( ui.table->item( list[i].topRow(), COL2_IP )->text() );
}
accept();
}
Even stripping the function to just:
void Detect::on_Btn_clicked( void )
{
QList<QTableWidgetSelectionRange> list = ui.table->selectedRanges();
accept();
}
still causes the crash.
My debugger lists a stack trace of:
msvcr71d.dll!operator delete(void* pUserData=non-zero)
QTableWidgetSelectionRange::`scalar deleting destructor'()
QList<QTableWidgetSelectionRange>::node_destructQList<QTableWidgetSelectionRange>::Node*from=non-zero)
QList<QTableWidgetSelectionRange>::free(QListData::Data*data=non-zero)
QList<QTableWidgetSelectionRange>::~QList<QTableWidgetSelectionRange>()
Detect::on_Btn_clicked()
All data in the stack trace is non-zero so I don't think I've got a NULL pointer causing the problem. Is there some maintainence that must be done to the contents of the QList before the function ends?