mirror of
https://github.com/kovidgoyal/calibre.git
synced 2026-06-06 22:15:22 -04:00
Edit book: Fix crash on copy in Wayland with PyQt 6.10.1
Also has the advantage of fixing the PARAGRAPH_SEPARATOR issue for all copied text mimetypes.
This commit is contained in:
@@ -28,7 +28,6 @@ from qt.core import (
|
||||
QLabel,
|
||||
QLineEdit,
|
||||
QListView,
|
||||
QMimeData,
|
||||
QModelIndex,
|
||||
QPainter,
|
||||
QPalette,
|
||||
@@ -1279,8 +1278,12 @@ class PlainTextEdit(QPlainTextEdit): # {{{
|
||||
return self.selected_text_from_cursor(self.textCursor())
|
||||
|
||||
def createMimeDataFromSelection(self):
|
||||
ans = QMimeData()
|
||||
ans.setText(self.selected_text)
|
||||
ans = super().createMimeDataFromSelection()
|
||||
for format in ans.formats():
|
||||
if format.startswith('text/'):
|
||||
val = bytes(ans.data(format)).decode()
|
||||
val = unicodedata.normalize('NFC', val.replace(PARAGRAPH_SEPARATOR, '\n').rstrip('\0'))
|
||||
ans.setData(format, val.encode())
|
||||
return ans
|
||||
|
||||
def show_tooltip(self, ev):
|
||||
|
||||
Reference in New Issue
Block a user