From 3ebbbe7d38bc5a5dccc7953c7503b98a4e4006ea4424f7194ad9d22c428b11b4 Mon Sep 17 00:00:00 2001 From: Christophe Giboudeaux Date: Fri, 5 Nov 2021 06:45:46 +0000 Subject: [PATCH] Accepting request 929171 from home:alois:branches:KDE:Extra - Add subtitlecomposer-fix_empty_lines_crash.patch (fixes boo#1192342) OBS-URL: https://build.opensuse.org/request/show/929171 OBS-URL: https://build.opensuse.org/package/show/KDE:Extra/subtitlecomposer?expand=0&rev=30 --- subtitlecomposer-fix_empty_lines_crash.patch | 93 ++++++++++++++++++++ subtitlecomposer.changes | 6 ++ subtitlecomposer.spec | 2 + 3 files changed, 101 insertions(+) create mode 100644 subtitlecomposer-fix_empty_lines_crash.patch diff --git a/subtitlecomposer-fix_empty_lines_crash.patch b/subtitlecomposer-fix_empty_lines_crash.patch new file mode 100644 index 0000000..01b5c98 --- /dev/null +++ b/subtitlecomposer-fix_empty_lines_crash.patch @@ -0,0 +1,93 @@ +From 17811ce518f2db3db4ecb15c81ed774593715713 Mon Sep 17 00:00:00 2001 +From: Mladen Milinkovic +Date: Thu, 14 Oct 2021 02:32:16 +0200 +Subject: [PATCH] Fix crashes on empty lines list + +--- + src/gui/treeview/linesmodel.cpp | 15 ++++++++++++--- + src/gui/treeview/linesselectionmodel.cpp | 17 +++++++++++++---- + 2 files changed, 25 insertions(+), 7 deletions(-) + +diff --git a/src/gui/treeview/linesmodel.cpp b/src/gui/treeview/linesmodel.cpp +index e36c2dd..afcd1db 100644 +--- a/src/gui/treeview/linesmodel.cpp ++++ b/src/gui/treeview/linesmodel.cpp +@@ -314,12 +314,14 @@ LinesModel::onLinesRemoved(int firstIndex, int lastIndex) + void + LinesModel::onModelReset() + { +- beginResetModel(); +- endResetModel(); +- + LinesWidget *w = static_cast(parent()); + QItemSelectionModel *sm = w->selectionModel(); + ++ const QModelIndex prevIndex = sm->currentIndex();; ++ ++ beginResetModel(); ++ endResetModel(); ++ + if(sm->hasSelection()) { + if(!sm->currentIndex().isValid()) { + const QModelIndex idx = index(sm->selection().first().top()); +@@ -332,6 +334,13 @@ LinesModel::onModelReset() + sm->select(QItemSelection(first, last), QItemSelectionModel::ClearAndSelect); + } + sm->setCurrentIndex(first, QItemSelectionModel::Rows); ++ } else { ++ if(prevIndex.isValid() && !sm->currentIndex().isValid()) { ++ // model reset should invalidate current index and prevent signals ++ QSignalBlocker s(sm); // make sure nothing fires anyway ++ sm->setCurrentIndex(prevIndex, QItemSelectionModel::Rows); ++ } ++ sm->clear(); + } + + if(w->scrollFollowsModel()) +diff --git a/src/gui/treeview/linesselectionmodel.cpp b/src/gui/treeview/linesselectionmodel.cpp +index 2dc14d5..9a1ccd2 100644 +--- a/src/gui/treeview/linesselectionmodel.cpp ++++ b/src/gui/treeview/linesselectionmodel.cpp +@@ -28,7 +28,8 @@ LinesSelectionModel::LinesSelectionModel(LinesModel *model) + void + LinesSelectionModel::setCurrentIndex(const QModelIndex &index, QItemSelectionModel::SelectionFlags command) + { +- m_currentLine = static_cast(model())->subtitle()->line(index.row()); ++ Subtitle *sub = static_cast(model())->subtitle(); ++ m_currentLine = sub ? sub->line(index.row()) : nullptr; + QItemSelectionModel::setCurrentIndex(index, command); + } + +@@ -50,6 +51,9 @@ LinesSelectionModel::select(const QItemSelection &selection, QItemSelectionModel + m_selection.clear(); + + const Subtitle *subtitle = static_cast(model())->subtitle(); ++ if(!subtitle) ++ return; ++ + QModelIndexList sel = selection.indexes(); + while(!sel.empty()) { + const SubtitleLine *line = subtitle->line(sel.takeFirst().row()); +@@ -83,11 +87,16 @@ LinesSelectionModel::reset() + QItemSelectionModel::reset(); + m_resetInProgress = false; + +- if(m_currentLine) +- QItemSelectionModel::setCurrentIndex(model()->index(m_currentLine->index(), 0), QItemSelectionModel::Current); +- + const LinesModel *model = static_cast(this->model()); + Subtitle *subtitle = model->subtitle(); ++ if(!subtitle) { ++ QItemSelectionModel::clear(); ++ return; ++ } ++ ++ if(m_currentLine) ++ QItemSelectionModel::setCurrentIndex(model->index(m_currentLine->index(), 0), QItemSelectionModel::Current); ++ + const int lastCol = model->columnCount() - 1; + for(auto it = m_selection.cbegin(); it != m_selection.cend(); ++it) { + const SubtitleLine *line = *it; +-- +GitLab + diff --git a/subtitlecomposer.changes b/subtitlecomposer.changes index fa1c5aa..c3ad538 100644 --- a/subtitlecomposer.changes +++ b/subtitlecomposer.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Thu Nov 4 10:48:42 UTC 2021 - Luigi Baldoni + +- Add subtitlecomposer-fix_empty_lines_crash.patch + (fixes boo#1192342) + ------------------------------------------------------------------- Sat Oct 16 05:19:18 UTC 2021 - Luigi Baldoni diff --git a/subtitlecomposer.spec b/subtitlecomposer.spec index 332a4ea..8bd0da7 100644 --- a/subtitlecomposer.spec +++ b/subtitlecomposer.spec @@ -28,6 +28,8 @@ Source1: https://download.kde.org/stable/subtitlecomposer/%{name}-%{versi Source2: subtitlecomposer.keyring # PATCH-FIX-UPSTREAM subtitlecomposer-ARM_GLES.patch Patch0: subtitlecomposer-ARM_GLES.patch +# PATCH-FIX-UPSTREAM subtitlecomposer-fix_empty_lines_crash.patch +Patch1: subtitlecomposer-fix_empty_lines_crash.patch BuildRequires: cmake >= 3.10 BuildRequires: extra-cmake-modules BuildRequires: libQt5Widgets-private-headers-devel