summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Fl_win32.cxx26
-rw-r--r--src/Fl_x.cxx6
2 files changed, 27 insertions, 5 deletions
diff --git a/src/Fl_win32.cxx b/src/Fl_win32.cxx
index 47bf8d404..4b633c1e2 100644
--- a/src/Fl_win32.cxx
+++ b/src/Fl_win32.cxx
@@ -2397,11 +2397,11 @@ static const Fl_RGB_Image *find_best_icon(int ideal_width, const Fl_RGB_Image *i
if (best == NULL)
best = icons[i];
else {
- if (best->data_w() < ideal_width) {
- if (icons[i]->data_w() > best->data_w())
+ if (best->w() < ideal_width) {
+ if (icons[i]->w() > best->w())
best = icons[i];
} else {
- if ((icons[i]->data_w() >= ideal_width) && (icons[i]->data_w() < best->data_w()))
+ if ((icons[i]->w() >= ideal_width) && (icons[i]->w() < best->w()))
best = icons[i];
}
}
@@ -2424,11 +2424,27 @@ void Fl_WinAPI_Screen_Driver::default_icons(const Fl_RGB_Image *icons[], int cou
best_big = find_best_icon(GetSystemMetrics(SM_CXICON), icons, count);
best_small = find_best_icon(GetSystemMetrics(SM_CXSMICON), icons, count);
- if (best_big != NULL)
+ bool need_delete;
+ if (best_big != NULL) {
+ need_delete = false;
+ if (best_big->w() != best_big->data_w() || best_big->h() != best_big->data_h()) {
+ best_big = (Fl_RGB_Image *)best_big->copy();
+ need_delete = true;
+ }
default_big_icon = image_to_icon(best_big, true, 0, 0);
+ if (need_delete) delete best_big;
+ }
- if (best_small != NULL)
+ if (best_small != NULL) {
+ need_delete = false;
+ if (best_small->w() != best_small->data_w() ||
+ best_small->h() != best_small->data_h()) {
+ best_small = (Fl_RGB_Image *)best_small->copy();
+ need_delete = true;
+ }
default_small_icon = image_to_icon(best_small, true, 0, 0);
+ if (need_delete) delete best_small;
+ }
}
/** Sets the window icons using Windows' native HICON icon handles.
diff --git a/src/Fl_x.cxx b/src/Fl_x.cxx
index e5c970b0a..5b7e2a731 100644
--- a/src/Fl_x.cxx
+++ b/src/Fl_x.cxx
@@ -2707,6 +2707,11 @@ static void icons_to_property(const Fl_RGB_Image *icons[], int count,
const Fl_RGB_Image *image;
image = icons[i];
+ bool need_delete = false;
+ if (image->w() != image->data_w() || image->h() != image->data_h()) {
+ image = (Fl_RGB_Image*)image->copy();
+ need_delete = true;
+ }
data[0] = image->data_w();
data[1] = image->data_h();
@@ -2736,6 +2741,7 @@ static void icons_to_property(const Fl_RGB_Image *icons[], int count,
}
in += extra_data;
}
+ if (need_delete) delete image;
}
}