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.
Qt Code:
  1. void Detect::on_Btn_clicked( void )
  2. {
  3. QList<QTableWidgetSelectionRange> list = ui.table->selectedRanges();
  4. QStringList sList;
  5.  
  6. for ( int i = 0; i < list.count(); i++ )
  7. {
  8. if ( !sList.contains( ui.table->item( list[i].topRow(), COL2_IP )->text() ) )
  9. sList.append( ui.table->item( list[i].topRow(), COL2_IP )->text() );
  10. }
  11.  
  12. accept();
  13. }
To copy to clipboard, switch view to plain text mode 
Even stripping the function to just:
Qt Code:
  1. void Detect::on_Btn_clicked( void )
  2. {
  3. QList<QTableWidgetSelectionRange> list = ui.table->selectedRanges();
  4. accept();
  5. }
To copy to clipboard, switch view to plain text mode 
still causes the crash.

My debugger lists a stack trace of:
Qt Code:
  1. msvcr71d.dll!operator delete(void* pUserData=non-zero)
  2. QTableWidgetSelectionRange::`scalar deleting destructor'()
  3. QList<QTableWidgetSelectionRange>::node_destructQList<QTableWidgetSelectionRange>::Node*from=non-zero)
  4. QList<QTableWidgetSelectionRange>::free(QListData::Data*data=non-zero)
  5. QList<QTableWidgetSelectionRange>::~QList<QTableWidgetSelectionRange>()
  6. Detect::on_Btn_clicked()
To copy to clipboard, switch view to plain text mode 

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?