From 29a23176446e3dbe711c830663711e690ea6f85e Mon Sep 17 00:00:00 2001 From: Fred Gleason Date: Thu, 25 Apr 2024 15:17:51 -0400 Subject: [PATCH] 2024-04-25 Fred Gleason * Fixed a bug in rdlibrary(1) that could cause segfaults when deleting cut entries from a cart. Signed-off-by: Fred Gleason --- ChangeLog | 3 +++ lib/rdcutlistmodel.cpp | 19 ++++++++++++++++--- lib/rdcutlistmodel.h | 1 + 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index fbdb12bd..63e9a83c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -24715,3 +24715,6 @@ 2024-04-24 Fred Gleason * Incremented the package version to 4.2.1 * Incremented the Python API version to 4.2.1. +2024-04-25 Fred Gleason + * Fixed a bug in rdlibrary(1) that could cause segfaults when + deleting cut entries from a cart. diff --git a/lib/rdcutlistmodel.cpp b/lib/rdcutlistmodel.cpp index 91df995a..145acc10 100644 --- a/lib/rdcutlistmodel.cpp +++ b/lib/rdcutlistmodel.cpp @@ -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;irow.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\n", + d_texts.at(i).at(12).toString().toUtf8().constData(), + i,d_row_index.at(i)); + } + printf("*****************\n"); +} diff --git a/lib/rdcutlistmodel.h b/lib/rdcutlistmodel.h index 17b95659..80db9260 100644 --- a/lib/rdcutlistmodel.h +++ b/lib/rdcutlistmodel.h @@ -68,6 +68,7 @@ class RDCutListModel : public QAbstractTableModel RDCart::Validity ValidateCut(RDSqlQuery *q,unsigned offset, RDCart::Validity prev_validity, const QDateTime &datetime); + void DumpIndex(const QString &str) const; QPalette d_palette; QFont d_font; QList d_headers;