2024-04-25 Fred Gleason <fredg@paravelsystems.com>

* Fixed a bug in rdlibrary(1) that could cause segfaults when
	deleting cut entries from a cart.

Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
This commit is contained in:
Fred Gleason
2024-04-25 15:17:51 -04:00
parent a22c8f59ad
commit 29a2317644
3 changed files with 20 additions and 3 deletions

View File

@@ -194,11 +194,11 @@ QModelIndex RDCutListModel::addCut(const QString &name)
void RDCutListModel::removeCut(const QModelIndex &row)
{
beginResetModel();
d_texts.removeAt(d_row_index.at(row.row()));
d_colors.removeAt(d_row_index.at(row.row()));
d_texts.removeAt(row.row());
d_colors.removeAt(row.row());
d_row_index.removeAt(row.row());
for(int i=0;i<d_row_index.size();i++) {
if(d_row_index.at(i)>row.row()) {
if(d_row_index.at(i)>=row.row()) {
d_row_index[i]--;
}
}
@@ -542,3 +542,16 @@ RDCart::Validity RDCutListModel::ValidateCut(RDSqlQuery *q,unsigned offset,
return RDCart::AlwaysValid;
}
void RDCutListModel::DumpIndex(const QString &str) const
{
printf("* %s ****************\n",str.toUtf8().constData());
printf("SIZE: %d\n",d_row_index.size());
for(int i=0;i<d_row_index.size();i++) {
printf("%s - %d => %d\n",
d_texts.at(i).at(12).toString().toUtf8().constData(),
i,d_row_index.at(i));
}
printf("*****************\n");
}