macOS: Workaround for regression in Qt 6.10 that causes a crash when trying to save a QPixmap from the clipboard as JPEG data. Fixes #2139397 [Crash when pasting cover image](https://bugs.launchpad.net/calibre/+bug/2139397)

This commit is contained in:
Kovid Goyal
2026-01-30 11:38:52 +05:30
parent c7a81b6198
commit 166548a9d3
2 changed files with 5 additions and 1 deletions
+3 -1
View File
@@ -41,7 +41,7 @@ from qt.core import (
)
from calibre import fit_image, sanitize_file_name
from calibre.constants import DEBUG, config_dir, iswindows
from calibre.constants import DEBUG, config_dir, ismacos, iswindows
from calibre.db.constants import DATA_DIR_NAME, DATA_FILE_PATTERN, NO_SEARCH_LINK, RESOURCE_URL_SCHEME
from calibre.ebooks import BOOK_EXTENSIONS
from calibre.ebooks.metadata.book.base import Metadata, field_metadata
@@ -990,6 +990,8 @@ class CoverView(QWidget): # {{{
pmap = cb.pixmap()
if pmap.isNull() and cb.supportsSelection():
pmap = cb.pixmap(QClipboard.Mode.Selection)
if ismacos: # Without this there is a crash when Qt tries to save this pixmap as JPEG data
pmap = pmap.copy()
if not pmap.isNull():
self.update_cover(pmap)
+2
View File
@@ -321,6 +321,8 @@ class ImageDropMixin: # {{{
pmap = cb.pixmap()
if pmap.isNull() and cb.supportsSelection():
pmap = cb.pixmap(QClipboard.Mode.Selection)
if ismacos: # Without this there is a crash when Qt tries to save this pixmap as JPEG data
pmap = pmap.copy()
if not pmap.isNull():
self.set_pixmap(pmap)
self.cover_changed.emit(