mirror of
https://github.com/kovidgoyal/calibre.git
synced 2026-05-08 10:32:28 +00:00
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:
@@ -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)
|
||||
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user