Control: tags 1018922 + patch
Control: tags 1018922 + pending

Dear maintainer,

I've prepared an NMU for kbibtex (versioned as 0.9.90-1.1) and uploaded 
it to DELAYED/1. Please feel free to tell me if I should cancel it.

cu
Adrian
diff -Nru kbibtex-0.9.90/debian/changelog kbibtex-0.9.90/debian/changelog
--- kbibtex-0.9.90/debian/changelog	2021-01-12 02:04:01.000000000 +0200
+++ kbibtex-0.9.90/debian/changelog	2023-02-07 18:22:51.000000000 +0200
@@ -1,3 +1,11 @@
+kbibtex (0.9.90-1.1) unstable; urgency=medium
+
+  * Non-maintainer upload.
+  * Add upstream fixes for crashes with newer Qt versions.
+    (Closes: #1018922)
+
+ -- Adrian Bunk <b...@debian.org>  Tue, 07 Feb 2023 18:22:51 +0200
+
 kbibtex (0.9.90-1) unstable; urgency=medium
 
   * New upstream release:
diff -Nru kbibtex-0.9.90/debian/patches/0001-Fix-crash-with-newer-Qt-versions.patch kbibtex-0.9.90/debian/patches/0001-Fix-crash-with-newer-Qt-versions.patch
--- kbibtex-0.9.90/debian/patches/0001-Fix-crash-with-newer-Qt-versions.patch	1970-01-01 02:00:00.000000000 +0200
+++ kbibtex-0.9.90/debian/patches/0001-Fix-crash-with-newer-Qt-versions.patch	2023-02-07 18:22:51.000000000 +0200
@@ -0,0 +1,28 @@
+From 84b0551eb141b3a7904ceec158d040200c995023 Mon Sep 17 00:00:00 2001
+From: Albert Astals Cid <aa...@kde.org>
+Date: Thu, 8 Apr 2021 22:07:15 +0200
+Subject: Fix crash with newer Qt versions
+
+Assign m_internalModel before calling into
+QSortFilterProxyModel::setSourceModel since that can end up calling filterAcceptsRow
+---
+ src/gui/file/sortfilterfilemodel.cpp | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/gui/file/sortfilterfilemodel.cpp b/src/gui/file/sortfilterfilemodel.cpp
+index 73707cec..87657aa2 100644
+--- a/src/gui/file/sortfilterfilemodel.cpp
++++ b/src/gui/file/sortfilterfilemodel.cpp
+@@ -40,8 +40,8 @@ SortFilterFileModel::SortFilterFileModel(QObject *parent)
+ 
+ void SortFilterFileModel::setSourceModel(QAbstractItemModel *model)
+ {
+-    QSortFilterProxyModel::setSourceModel(model);
+     m_internalModel = dynamic_cast<FileModel *>(model);
++    QSortFilterProxyModel::setSourceModel(model);
+ }
+ 
+ FileModel *SortFilterFileModel::fileSourceModel() const
+-- 
+2.30.2
+
diff -Nru kbibtex-0.9.90/debian/patches/0001-Fixing-crash-when-opening-.bib-file.patch kbibtex-0.9.90/debian/patches/0001-Fixing-crash-when-opening-.bib-file.patch
--- kbibtex-0.9.90/debian/patches/0001-Fixing-crash-when-opening-.bib-file.patch	1970-01-01 02:00:00.000000000 +0200
+++ kbibtex-0.9.90/debian/patches/0001-Fixing-crash-when-opening-.bib-file.patch	2023-02-07 18:22:51.000000000 +0200
@@ -0,0 +1,180 @@
+From ee125af91d7d4e8dfc8927cad85694b55de27a84 Mon Sep 17 00:00:00 2001
+From: Thomas Fischer <fisc...@unix-ag.uni-kl.de>
+Date: Sat, 31 Dec 2022 00:00:04 +0100
+Subject: Fixing crash when opening .bib file
+
+In certain situations, also depending on Linux distributions (varying Qt
+and KDE Frameworks versions), opening a bibliography file can cause
+crashes (segmentation faults) due to an invalid model or its underlying
+data.
+
+This commit changes the order of two instructions. Now first an internal
+variable is properly set. Only then an update on the model is applied.
+
+The largest part of this commit is a new test that reproducibly crashes
+without the changed order of two instructions, but passes after the fix
+has been applied.
+
+This commit is a forward-port of commit 4aea6ed35b1629b3dba65a44 from
+branch 'kbibtex/0.10'.
+
+CCBUG: 433084
+CCBUG: 453455
+---
+ src/test/CMakeLists.txt     | 36 ++++++++++++++++++++
+ src/test/kbibtexguitest.cpp | 66 +++++++++++++++++++++++++++++++++++++
+ 2 files changed, 102 insertions(+)
+ create mode 100644 src/test/kbibtexguitest.cpp
+
+diff --git a/src/test/CMakeLists.txt b/src/test/CMakeLists.txt
+index 161a11e3..bc5880ec 100644
+--- a/src/test/CMakeLists.txt
++++ b/src/test/CMakeLists.txt
+@@ -42,11 +42,17 @@ set(
+     kbibtexdatatest.cpp
+ )
+ 
++set(
++    kbibtexguitest_SRCS
++    kbibtexguitest.cpp
++)
++
+ if(UNITY_BUILD AND NOT WIN32) # FIXME: Unity build of programs breaks on Windows
+     enable_unity_build(kbibtextest kbibtextest_SRCS)
+     enable_unity_build(kbibtexnetworkingtest kbibtexnetworkingtest_SRCS)
+     enable_unity_build(kbibtexiotest kbibtexiotest_SRCS)
+     enable_unity_build(kbibtexdatatest kbibtexdatatest_SRCS)
++    enable_unity_build(kbibtexguitest kbibtexdatatest_SRCS)
+ endif(UNITY_BUILD AND NOT WIN32)
+ 
+ add_executable(
+@@ -85,6 +91,15 @@ add_dependencies(kbibtexdatatest
+     generate-kbibtex-git-info
+ )
+ 
++add_executable(
++    kbibtexguitest
++    ${kbibtexguitest_SRCS}
++)
++
++add_dependencies(kbibtexguitest
++    generate-kbibtex-git-info
++)
++
+ target_link_libraries(kbibtextest
+     Qt5::Core
+     KF5::KIOCore
+@@ -138,10 +153,24 @@ target_include_directories(kbibtexdatatest
+         ${CMAKE_BINARY_DIR}
+ )
+ 
++target_link_libraries(kbibtexguitest
++    PRIVATE
++        Qt5::Test
++        KBibTeX::Global
++        KBibTeX::Data
++        KBibTeX::GUI
++)
++
++target_include_directories(kbibtexguitest
++    PRIVATE
++        ${CMAKE_BINARY_DIR}
++)
++
+ ecm_mark_as_test(
+     kbibtexnetworkingtest
+     kbibtexiotest
+     kbibtexdatatest
++    kbibtexguitest
+ )
+ 
+ add_test(
+@@ -165,6 +194,13 @@ add_test(
+     kbibtexdatatest
+ )
+ 
++add_test(
++    NAME
++    kbibtexguitest
++    COMMAND
++    kbibtexguitest
++)
++
+ if(TESTSET_DIRECTORY)
+     set(
+         kbibtexfilestest_SRCS
+diff --git a/src/test/kbibtexguitest.cpp b/src/test/kbibtexguitest.cpp
+new file mode 100644
+index 00000000..e8ab244e
+--- /dev/null
++++ b/src/test/kbibtexguitest.cpp
+@@ -0,0 +1,66 @@
++/***************************************************************************
++ *   Copyright (C) 2022 by Thomas Fischer <fisc...@unix-ag.uni-kl.de>      *
++ *                                                                         *
++ *   This program is free software; you can redistribute it and/or modify  *
++ *   it under the terms of the GNU General Public License as published by  *
++ *   the Free Software Foundation; either version 2 of the License, or     *
++ *   (at your option) any later version.                                   *
++ *                                                                         *
++ *   This program is distributed in the hope that it will be useful,       *
++ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
++ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
++ *   GNU General Public License for more details.                          *
++ *                                                                         *
++ *   You should have received a copy of the GNU General Public License     *
++ *   along with this program; if not, see <https://www.gnu.org/licenses/>. *
++ ***************************************************************************/
++
++#include <QtTest>
++
++#include <field/FieldLineEdit>
++#include <File>
++#include <Entry>
++#include <models/FileModel>
++#include <file/SortFilterFileModel>
++
++class KBibTeXGUITest : public QObject
++{
++    Q_OBJECT
++
++private slots:
++    void initTestCase();
++
++    void sortedFilterFileModelSetSourceModel();
++
++private:
++};
++
++void KBibTeXGUITest::initTestCase()
++{
++    // nothing
++}
++
++void KBibTeXGUITest::sortedFilterFileModelSetSourceModel()
++{
++    File *bibTeXfile = new File();
++    // Kirsop, Barbara, and Leslie Chan. (2005) Transforming access to research literature for developing countries. Serials Reviews, 31(4): 246–255.
++    QSharedPointer<Entry> entry(new Entry(Entry::etArticle, QStringLiteral("kirsop2005accessrelitdevcountries")));
++    bibTeXfile->append(entry);
++    entry->insert(Entry::ftTitle, Value() << QSharedPointer<PlainText>(new PlainText(QStringLiteral("Transforming access to research literature for developing countries"))));
++    entry->insert(Entry::ftAuthor, Value() << QSharedPointer<Person>(new Person(QStringLiteral("Barbara"), QStringLiteral("Kirsop"))) << QSharedPointer<Person>(new Person(QStringLiteral("Leslie"), QStringLiteral("Chan"))));
++    entry->insert(Entry::ftYear, Value() << QSharedPointer<PlainText>(new PlainText(QStringLiteral("2005"))));
++    entry->insert(Entry::ftJournal, Value() << QSharedPointer<PlainText>(new PlainText(QStringLiteral("Serials Reviews"))));
++    entry->insert(Entry::ftVolume, Value() << QSharedPointer<PlainText>(new PlainText(QStringLiteral("31"))));
++    entry->insert(Entry::ftNumber, Value() << QSharedPointer<PlainText>(new PlainText(QStringLiteral("4"))));
++    entry->insert(Entry::ftPages, Value() << QSharedPointer<PlainText>(new PlainText(QStringLiteral("246--255"))));
++
++    QPointer<FileModel> model = new FileModel();
++    model->setBibliographyFile(bibTeXfile);
++    QPointer<SortFilterFileModel> sortFilterProxyModel = new SortFilterFileModel();
++    sortFilterProxyModel->setSourceModel(model.data());
++    QCOMPARE(sortFilterProxyModel->rowCount(), 1);
++}
++
++QTEST_MAIN(KBibTeXGUITest)
++
++#include "kbibtexguitest.moc"
+-- 
+2.30.2
+
diff -Nru kbibtex-0.9.90/debian/patches/series kbibtex-0.9.90/debian/patches/series
--- kbibtex-0.9.90/debian/patches/series	1970-01-01 02:00:00.000000000 +0200
+++ kbibtex-0.9.90/debian/patches/series	2023-02-07 18:22:51.000000000 +0200
@@ -0,0 +1,2 @@
+0001-Fix-crash-with-newer-Qt-versions.patch
+0001-Fixing-crash-when-opening-.bib-file.patch

Reply via email to