[arch-commits] Commit in calibre/trunk (2 files)

Eli Schwartz eschwartz at archlinux.org
Fri Aug 28 21:26:48 UTC 2020


    Date: Friday, August 28, 2020 @ 21:26:48
  Author: eschwartz
Revision: 691292

upgpkg: calibre 4.23.0-2: backport workaround for FS#67690

Added:
  calibre/trunk/Dont-subclass-QLineEdit-in-QDateEdit.patch
Modified:
  calibre/trunk/PKGBUILD

--------------------------------------------+
 Dont-subclass-QLineEdit-in-QDateEdit.patch |  180 +++++++++++++++++++++++++++
 PKGBUILD                                   |    7 -
 2 files changed, 186 insertions(+), 1 deletion(-)

Added: Dont-subclass-QLineEdit-in-QDateEdit.patch
===================================================================
--- Dont-subclass-QLineEdit-in-QDateEdit.patch	                        (rev 0)
+++ Dont-subclass-QLineEdit-in-QDateEdit.patch	2020-08-28 21:26:48 UTC (rev 691292)
@@ -0,0 +1,180 @@
+From 4dac21286af92d34f526848c9e5597ca0960a300 Mon Sep 17 00:00:00 2001
+From: Kovid Goyal <kovid at kovidgoyal.net>
+Date: Tue, 25 Aug 2020 18:34:09 +0530
+Subject: [PATCH 1/2] Dont subclass QLineEdit in QDateEdit
+
+This causes crashed on Linux with accessibility enabled. Fixes #1892646 [Mysterious crash in Qt since bug #1885004 when clicking "Edit Metadata"](https://bugs.launchpad.net/calibre/+bug/1892646)
+
+(cherry picked from commit 35f770955e07c4b39c5d694bc070d820ad4996d7)
+
+# Conflicts:
+#	src/calibre/gui2/widgets2.py
+---
+ src/calibre/gui2/widgets2.py | 70 +++++++++++++++++-------------------
+ 1 file changed, 33 insertions(+), 37 deletions(-)
+
+diff --git a/src/calibre/gui2/widgets2.py b/src/calibre/gui2/widgets2.py
+index 7feef8a2ef..d06b40c2db 100644
+--- a/src/calibre/gui2/widgets2.py
++++ b/src/calibre/gui2/widgets2.py
+@@ -9,10 +9,10 @@ import weakref
+ from PyQt5.Qt import (
+     QApplication, QByteArray, QCalendarWidget, QCheckBox, QColor, QColorDialog,
+     QComboBox, QDate, QDateTime, QDateTimeEdit, QDialog, QDialogButtonBox, QFont,
+-    QFontInfo, QFontMetrics, QIcon, QKeySequence, QLabel, QLayout, QLineEdit, QMenu,
++    QFontInfo, QFontMetrics, QIcon, QKeySequence, QLabel, QLayout, QMenu,
+     QMimeData, QPalette, QPixmap, QPoint, QPushButton, QRect, QScrollArea, QSize,
+     QSizePolicy, QStyle, QStyledItemDelegate, Qt, QTabWidget, QTextBrowser,
+-    QToolButton, QUndoCommand, QUndoStack, QWidget, pyqtSignal, pyqtSlot
++    QToolButton, QUndoCommand, QUndoStack, QWidget, pyqtSignal
+ )
+ 
+ from calibre.ebooks.metadata import rating_to_stars
+@@ -128,12 +128,13 @@ def access_key(k):
+     return ''
+ 
+ 
+-def populate_standard_spinbox_context_menu(spinbox, menu, add_clear=False):
++def populate_standard_spinbox_context_menu(spinbox, menu, add_clear=False, use_self_for_copy_actions=False):
+     m = menu
+     le = spinbox.lineEdit()
+-    m.addAction(_('Cu&t') + access_key(QKeySequence.Cut), le.cut).setEnabled(not le.isReadOnly() and le.hasSelectedText())
+-    m.addAction(_('&Copy') + access_key(QKeySequence.Copy), le.copy).setEnabled(le.hasSelectedText())
+-    m.addAction(_('&Paste') + access_key(QKeySequence.Paste), le.paste).setEnabled(not le.isReadOnly())
++    ca = spinbox if use_self_for_copy_actions else le
++    m.addAction(_('Cu&t') + access_key(QKeySequence.Cut), ca.cut).setEnabled(not le.isReadOnly() and le.hasSelectedText())
++    m.addAction(_('&Copy') + access_key(QKeySequence.Copy), ca.copy).setEnabled(le.hasSelectedText())
++    m.addAction(_('&Paste') + access_key(QKeySequence.Paste), ca.paste).setEnabled(not le.isReadOnly())
+     m.addAction(_('Delete') + access_key(QKeySequence.Delete), le.del_).setEnabled(not le.isReadOnly() and le.hasSelectedText())
+     m.addSeparator()
+     m.addAction(_('Select &all') + access_key(QKeySequence.SelectAll), spinbox.selectAll)
+@@ -557,25 +558,6 @@ def to_plain_text(self):
+     return ans.rstrip('\0')
+ 
+ 
+-class LineEditForDateTimeEdit(QLineEdit):
+-
+-    date_time_pasted = pyqtSignal(object)
+-    date_time_copied = pyqtSignal(object)
+-    MIME_TYPE = 'application/x-calibre-datetime-value'
+-
+-    @pyqtSlot()
+-    def copy(self):
+-        self.date_time_copied.emit(self.selectedText())
+-
+-    @pyqtSlot()
+-    def paste(self):
+-        md = QApplication.instance().clipboard().mimeData()
+-        if md.hasFormat(self.MIME_TYPE):
+-            self.date_time_pasted.emit(QDateTime.fromString(md.data(self.MIME_TYPE).data().decode('ascii'), Qt.ISODate))
+-        else:
+-            QLineEdit.paste(self)
+-
+-
+ class CalendarWidget(QCalendarWidget):
+ 
+     def showEvent(self, ev):
+@@ -585,12 +567,10 @@ class CalendarWidget(QCalendarWidget):
+ 
+ class DateTimeEdit(QDateTimeEdit):
+ 
++    MIME_TYPE = 'application/x-calibre-datetime-value'
++
+     def __init__(self, parent=None):
+         QDateTimeEdit.__init__(self, parent)
+-        le = LineEditForDateTimeEdit(self)
+-        self.setLineEdit(le)
+-        le.date_time_pasted.connect(self.date_time_pasted, type=Qt.QueuedConnection)
+-        le.date_time_copied.connect(self.date_time_copied, type=Qt.QueuedConnection)
+         self.setMinimumDateTime(UNDEFINED_QDATETIME)
+         self.setCalendarPopup(True)
+         self.cw = CalendarWidget(self)
+@@ -598,14 +578,27 @@ class DateTimeEdit(QDateTimeEdit):
+         self.setCalendarWidget(self.cw)
+         self.setSpecialValueText(_('Undefined'))
+ 
+-    def date_time_copied(self, text):
++    @property
++    def mime_data_for_copy(self):
+         md = QMimeData()
+-        md.setText(text or self.dateTime().toString())
+-        md.setData(LineEditForDateTimeEdit.MIME_TYPE, self.dateTime().toString(Qt.ISODate).encode('ascii'))
++        md.setText(self.dateTime().toString())
++        md.setData(self.MIME_TYPE, self.dateTime().toString(Qt.ISODate).encode('ascii'))
++        return md
++
++    def copy(self):
++        QApplication.instance().clipboard().setMimeData(self.mime_data_for_copy)
++
++    def cut(self):
++        md = self.mime_data_for_copy
++        self.lineEdit().cut()
+         QApplication.instance().clipboard().setMimeData(md)
+ 
+-    def date_time_pasted(self, qt_dt):
+-        self.setDateTime(qt_dt)
++    def paste(self):
++        md = QApplication.instance().clipboard().mimeData()
++        if md.hasFormat(self.MIME_TYPE):
++            self.setDateTime(QDateTime.fromString(md.data(self.MIME_TYPE).data().decode('ascii'), Qt.ISODate))
++        else:
++            self.lineEdit().paste()
+ 
+     def create_context_menu(self):
+         m = QMenu(self)
+@@ -614,7 +607,7 @@ class DateTimeEdit(QDateTimeEdit):
+         m.addAction(_('Set date to today') + '\t' + QKeySequence(Qt.Key_Equal).toString(QKeySequence.NativeText),
+                     self.today_date)
+         m.addSeparator()
+-        populate_standard_spinbox_context_menu(self, m)
++        populate_standard_spinbox_context_menu(self, m, use_self_for_copy_actions=True)
+         return m
+ 
+     def contextMenuEvent(self, ev):
+@@ -635,10 +628,13 @@ class DateTimeEdit(QDateTimeEdit):
+             self.today_date()
+             ev.accept()
+         elif ev.matches(QKeySequence.Copy):
+-            self.lineEdit().copy()
++            self.copy()
++            ev.accept()
++        elif ev.matches(QKeySequence.Cut):
++            self.cut()
+             ev.accept()
+         elif ev.matches(QKeySequence.Paste):
+-            self.lineEdit().paste()
++            self.paste()
+             ev.accept()
+         else:
+             return QDateTimeEdit.keyPressEvent(self, ev)
+-- 
+2.28.0
+
+
+From 187eb99396d550e15ef4db2db47d08921d49875f Mon Sep 17 00:00:00 2001
+From: Kovid Goyal <kovid at kovidgoyal.net>
+Date: Tue, 25 Aug 2020 18:43:10 +0530
+Subject: [PATCH 2/2] Copy should only copy selected text if there is any
+
+(cherry picked from commit 69a9ffadf523b871ec3eb4b645ef83ed6fd1a908)
+---
+ src/calibre/gui2/widgets2.py | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/src/calibre/gui2/widgets2.py b/src/calibre/gui2/widgets2.py
+index d06b40c2db..facd910151 100644
+--- a/src/calibre/gui2/widgets2.py
++++ b/src/calibre/gui2/widgets2.py
+@@ -581,7 +581,8 @@ class DateTimeEdit(QDateTimeEdit):
+     @property
+     def mime_data_for_copy(self):
+         md = QMimeData()
+-        md.setText(self.dateTime().toString())
++        text = self.lineEdit().selectedText()
++        md.setText(text or self.dateTime().toString())
+         md.setData(self.MIME_TYPE, self.dateTime().toString(Qt.ISODate).encode('ascii'))
+         return md
+ 
+-- 
+2.28.0
+

Modified: PKGBUILD
===================================================================
--- PKGBUILD	2020-08-28 20:57:21 UTC (rev 691291)
+++ PKGBUILD	2020-08-28 21:26:48 UTC (rev 691292)
@@ -9,7 +9,7 @@
 pkgbase=calibre
 pkgname=('calibre' 'calibre-common' 'calibre-python3')
 pkgver=4.23.0
-pkgrel=1
+pkgrel=2
 pkgdesc="Ebook management application"
 arch=('x86_64')
 url="https://calibre-ebook.com/"
@@ -27,14 +27,17 @@
 checkdepends=('xorg-server-xvfb')
 source=("https://download.calibre-ebook.com/${pkgver}/calibre-${pkgver}.tar.xz"
         "https://calibre-ebook.com/signatures/${pkgbase}-${pkgver}.tar.xz.sig"
+        "Dont-subclass-QLineEdit-in-QDateEdit.patch"
         "0001-De-vendor-pychm.patch"
         "calibre-alternatives.sh")
 sha256sums=('16de51473cf0e336f946a57251a1e4f4fbba1f857f17d8fc14aa132e7eb59518'
             'SKIP'
+            'fb451d9d845a291412f8c26d1f39699d56c70d955b128f32aeed223aedcbadf3'
             'f7b829aea1d33818808cbeeb9a295e18e49edf619a5bc89b8315c88f56ce4d25'
             '940cc7081d0a64ba363bb0e1a1d8e0563c676458f90db845f2fbdd4195c075b3')
 b2sums=('3a950ac2b3aade547bb686cc99b963357e76b5931049ecb4a5e09ddaf1db26c74fa3b4ebd74e42d83f68c5c9827c534c0247a3c6a9b000641a778cfe5ac33599'
         'SKIP'
+        '886e66191f63959b8bcc8b2de2b7c431260100f9f3b54dc0e5b7dbeae4ea908fda0d8dc75e1aa990edde79ae29d5ecd4d5a91a204914c208d0b40fa1cbdb2cf0'
         'c35181c70084813772c4d593311b48b3e3bcc3b4e9e8ee58112b9beab2bbc0de1ee22aafc3d06cfd812f87a2e91292f7b7f1dc5f522c55440f415b6b265d5671'
         '543df218dfd2d4152a941ab57118d69bf4c6927e8020ee53c9a8b38efe9c89f032dc6385207e134cc9f69bfdc9cbcf63cd92fa6ea1647cbd534c5a511a5d1e91')
 validpgpkeys=('3CE1780F78DD88DF45194FD706BC317B515ACE7C') # Kovid Goyal (New longer key) <kovid at kovidgoyal.net>
@@ -58,6 +61,8 @@
     # devendor pychm now, from the py3 building branch:
     # https://github.com/kovidgoyal/calibre/commit/959b7e3fafff5faad6ae59263f825b23c7563dd4
     patch -p1 -i ../0001-De-vendor-pychm.patch
+    # FS#67690 backport workaround for https://bugreports.qt.io/browse/QTBUG-86232
+    patch -p1 -i ../Dont-subclass-QLineEdit-in-QDateEdit.patch
 
     cd resources
 



More information about the arch-commits mailing list