diff --git a/src/ui/dialog/filedialogimpl-win32.cpp b/src/ui/dialog/filedialogimpl-win32.cpp index bd6cba557e7e59ce9d3f759372670c528a226b1b..31d248141994a7c50e6b7adbae364ec821a53fd0 100644 --- a/src/ui/dialog/filedialogimpl-win32.cpp +++ b/src/ui/dialog/filedialogimpl-win32.cpp @@ -1054,18 +1054,29 @@ bool FileOpenDialogImplWin32::set_image_preview() _mutex->lock(); - try { - _preview_bitmap_image = Gdk::Pixbuf::create_from_file(path); - if (_preview_bitmap_image) { + constexpr int preview_size = 512; + + int width = 0; + int height = 0; + if (gdk_pixbuf_get_file_info(path.c_str(), &width, &height) && + width > 0 && height > 0) + { + GdkPixbuf *c_pixbuf = gdk_pixbuf_new_from_file_at_scale(path.c_str(), + preview_size, + preview_size, + TRUE, + nullptr); + if (c_pixbuf) { + _preview_bitmap_image = Glib::wrap(c_pixbuf); + _preview_image_width = _preview_bitmap_image->get_width(); - _preview_document_width = _preview_image_width; + _preview_document_width = width; _preview_image_height = _preview_bitmap_image->get_height(); - _preview_document_height = _preview_image_height; + _preview_document_height = height; + successful = true; } } - catch (const Gdk::PixbufError&) {} - catch (const Glib::FileError&) {} _mutex->unlock(); diff --git a/src/util/gobjectptr.h b/src/util/gobjectptr.h index 1f4f37136de055c20b6bec367305583f5a5a1601..aa142e765bbabc6671398bbf2da1a3fbe3bcfe9d 100644 --- a/src/util/gobjectptr.h +++ b/src/util/gobjectptr.h @@ -20,7 +20,7 @@ public: GObjectPtr() = default; explicit GObjectPtr(T *p, bool add_ref = false) : _p(p) { if (add_ref) _ref(); } GObjectPtr(GObjectPtr const &other) : _p(other._p) { _ref(); } - GObjectPtr &operator=(GObjectPtr const &other) { if (&other != this) { _unref(); _p = other.p; _ref(); } return *this; } + GObjectPtr &operator=(GObjectPtr const &other) { if (&other != this) { _unref(); _p = other._p; _ref(); } return *this; } GObjectPtr(GObjectPtr &&other) noexcept : _p(other._p) { other._p = nullptr; } GObjectPtr &operator=(GObjectPtr &&other) { if (&other != this) { _unref(); _p = other._p; other._p = nullptr; } return *this; } ~GObjectPtr() { _unref(); }