summaryrefslogtreecommitdiff
path: root/plugins/NewStory/src
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2024-04-05 18:20:03 +0300
committerGeorge Hazan <george.hazan@gmail.com>2024-04-05 18:20:03 +0300
commitbf20bc908d56fd71d482c37fed713d910b87d563 (patch)
tree665dfb0d436637dbbc1f20779377046f720aede7 /plugins/NewStory/src
parent11db9bbe6aa2b7832c2b7896b1e0bb51b5530553 (diff)
NewStory: fix for loading non-existent images
Diffstat (limited to 'plugins/NewStory/src')
-rw-r--r--plugins/NewStory/src/webpage.cpp19
1 files changed, 13 insertions, 6 deletions
diff --git a/plugins/NewStory/src/webpage.cpp b/plugins/NewStory/src/webpage.cpp
index 7ffa2795da..a85d0587a9 100644
--- a/plugins/NewStory/src/webpage.cpp
+++ b/plugins/NewStory/src/webpage.cpp
@@ -294,9 +294,11 @@ Bitmap* NSWebPage::load_image(const wchar_t *pwszUrl)
if (img != m_images.end() && img->second)
return (Bitmap *)img->second;
- uint_ptr newImg = get_image(pwszUrl, false);
- add_image(pwszUrl, newImg);
- return (Bitmap *)newImg;
+ if (uint_ptr newImg = get_image(pwszUrl, false)) {
+ add_image(pwszUrl, newImg);
+ return (Bitmap *)newImg;
+ }
+ return 0;
}
void NSWebPage::load_image(const char *src, const char *baseurl, bool redraw_on_ready)
@@ -308,8 +310,8 @@ void NSWebPage::load_image(const char *src, const char *baseurl, bool redraw_on_
if (m_images.count(url) == 0) {
lck.unlock();
- uint_ptr img = get_image(url.c_str(), redraw_on_ready);
- add_image(url.c_str(), img);
+ if (uint_ptr img = get_image(url.c_str(), redraw_on_ready))
+ add_image(url.c_str(), img);
}
}
@@ -661,7 +663,12 @@ uint_ptr NSWebPage::get_image(LPCWSTR url_or_path, bool)
if (!mir_wstrncmp(url_or_path, L"file://", 7))
url_or_path += 7;
- return (uint_ptr)new Gdiplus::Bitmap(url_or_path);
+ auto *pImage = new Gdiplus::Bitmap(url_or_path);
+ if (pImage->GetLastStatus() != Ok) {
+ delete pImage;
+ return 0;
+ }
+ return (uint_ptr)pImage;
}
void NSWebPage::get_client_rect(position &pos) const