From 84ca8dfd277abbcc51f280811a7aa3be54e3a2bc Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 21 Oct 2024 18:53:39 +0300 Subject: fixes #4250 (PopupPlus: occasional crash) + code cleaning --- plugins/Popup/src/bitmap_funcs.cpp | 19 ++----------------- plugins/Popup/src/bitmap_funcs.h | 10 +++++----- 2 files changed, 7 insertions(+), 22 deletions(-) diff --git a/plugins/Popup/src/bitmap_funcs.cpp b/plugins/Popup/src/bitmap_funcs.cpp index 2d8af56be2..8e11c2fb72 100644 --- a/plugins/Popup/src/bitmap_funcs.cpp +++ b/plugins/Popup/src/bitmap_funcs.cpp @@ -38,30 +38,15 @@ typedef long pu_koef; MyBitmap::MyBitmap() { - dcBmp = nullptr; - hBmp = nullptr; - bits = nullptr; - width = height = 0; - bitsSave = nullptr; } MyBitmap::MyBitmap(int w, int h) { - dcBmp = nullptr; - hBmp = nullptr; - bits = nullptr; - width = height = 0; - bitsSave = nullptr; allocate(w, h); } MyBitmap::MyBitmap(const wchar_t *fn) { - dcBmp = nullptr; - hBmp = nullptr; - bits = nullptr; - width = height = 0; - bitsSave = nullptr; loadFromFile(fn); } @@ -95,7 +80,7 @@ void MyBitmap::makeOpaqueRect(int x1, int y1, int x2, int y2) void MyBitmap::saveAlpha(int x, int y, int w, int h) { - if (x < 0 || y < 0) + if (x < 0 || y < 0 || !bits) return; if (!w) w = width; if (!h) h = height; @@ -124,7 +109,7 @@ void MyBitmap::saveAlpha(int x, int y, int w, int h) void MyBitmap::restoreAlpha(int x, int y, int w, int h) { - if (!bitsSave) + if (!bitsSave || !bits) return; GdiFlush(); diff --git a/plugins/Popup/src/bitmap_funcs.h b/plugins/Popup/src/bitmap_funcs.h index 6b8a4e2816..8f06900a30 100644 --- a/plugins/Popup/src/bitmap_funcs.h +++ b/plugins/Popup/src/bitmap_funcs.h @@ -35,11 +35,11 @@ public: }; private: - HBITMAP hBmpSave, hBmp; - HDC dcBmp; - COLOR32 *bits; - COLOR32 *bitsSave; - int width, height; + HBITMAP hBmpSave = 0, hBmp = 0; + HDC dcBmp = 0; + COLOR32 *bits = 0; + COLOR32 *bitsSave = 0; + int width = 0, height = 0; void freemem(); -- cgit v1.2.3