From: "Rodolfo García Peñas (kix)" <[email protected]>
The new function set_icon_image_from_image() sets the icon image using
a image provided as argument.
This function will be used to avoid call wIconUpdate() with the image
argument, doing the code easier and faster.
This patch calls unset_icon_image(), to free the icon image, to avoid
lost memory. After this patch, in winspector.c, the wIconUpdate() call
don't free the memory before update it.
---
src/icon.c | 11 +++++++++++
src/icon.h | 1 +
src/winspector.c | 23 ++++++++++++++++++-----
3 files changed, 30 insertions(+), 5 deletions(-)
diff --git a/src/icon.c b/src/icon.c
index 2c9b27d..eaca466 100644
--- a/src/icon.c
+++ b/src/icon.c
@@ -564,6 +564,17 @@ static void unset_icon_image(WIcon *icon)
}
}
+void set_icon_image_from_image(WIcon *icon, RImage *image)
+{
+ if (!icon)
+ return;
+
+ unset_icon_image(icon);
+
+ icon->file_image = NULL;
+ icon->file_image = image;
+}
+
void wIconUpdate(WIcon *icon, RImage *image)
{
WWindow *wwin = NULL;
diff --git a/src/icon.h b/src/icon.h
index 4e030a8..93b8145 100644
--- a/src/icon.h
+++ b/src/icon.h
@@ -73,5 +73,6 @@ char *wIconStore(WIcon *icon);
char *get_name_for_instance_class(char *wm_instance, char *wm_class);
void wIconSetHighlited(WIcon *icon, Bool flag);
+void set_icon_image_from_image(WIcon *icon, RImage *image);
#endif /* WMICON_H_ */
diff --git a/src/winspector.c b/src/winspector.c
index 8d5923a..acd2057 100644
--- a/src/winspector.c
+++ b/src/winspector.c
@@ -763,14 +763,27 @@ static void applySettings(WMButton *button,
InspectorPanel *panel)
* the icon text box has an icon path */
if (!WFLAGP(wwin, always_user_icon)) {
/* Change App Icon image, using the icon provided by
the client */
- if (wapp->app_icon)
- wIconUpdate(wapp->app_icon->icon,
-
get_rimage_icon_from_wm_hints(wapp->app_icon->icon));
+ if (wapp->app_icon) {
+ RImage *image =
get_rimage_icon_from_wm_hints(wapp->app_icon->icon);
+ if (image) {
+
set_icon_image_from_image(wapp->app_icon->icon, image);
+
update_icon_pixmap(wapp->app_icon->icon);
+ } else {
+ wIconUpdate(wapp->app_icon->icon, NULL);
+ }
+ }
/* Change icon image if the app is minimized,
* using the icon provided by the client */
- if (wwin->icon)
- wIconUpdate(wwin->icon,
get_rimage_icon_from_wm_hints(wwin->icon));
+ if (wwin->icon) {
+ RImage *image =
get_rimage_icon_from_wm_hints(wwin->icon);
+ if (image) {
+ set_icon_image_from_image(wwin->icon,
image);
+ update_icon_pixmap(wwin->icon);
+ } else {
+ wIconUpdate(wwin->icon, NULL);
+ }
+ }
} else {
/* Change App Icon image */
if (wapp->app_icon)
--
1.7.10.4
--
To unsubscribe, send mail to [email protected].