summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2024-10-21 18:53:39 +0300
committerGeorge Hazan <george.hazan@gmail.com>2024-10-21 18:53:39 +0300
commit84ca8dfd277abbcc51f280811a7aa3be54e3a2bc (patch)
treea0f76e02c439e6bf4acd9bf2f78d810b69be2bf3
parentee868b7339322e7222cb62741f397d97180c96cb (diff)
fixes #4250 (PopupPlus: occasional crash) + code cleaning
-rw-r--r--plugins/Popup/src/bitmap_funcs.cpp19
-rw-r--r--plugins/Popup/src/bitmap_funcs.h10
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();