From fb43f725830c7c296fc461133d99d1e9cd7b0dae Mon Sep 17 00:00:00 2001 From: Eduardo Bart Date: Fri, 25 Nov 2011 14:17:40 -0200 Subject: [PATCH] handle more errors on icon setting --- src/framework/platform/win32platform.cpp | 6 +++++- src/framework/platform/x11platform.cpp | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/framework/platform/win32platform.cpp b/src/framework/platform/win32platform.cpp index 025bcec2..7ba498dc 100644 --- a/src/framework/platform/win32platform.cpp +++ b/src/framework/platform/win32platform.cpp @@ -433,8 +433,10 @@ void Platform::setWindowIcon(const std::string& pngIcon) std::stringstream fin; g_resources.loadFile(pngIcon, fin); if(load_apng(fin, &apng) == 0) { - if(apng.bpp != 4) + if(apng.bpp != 4) { logError("could not set app icon, icon image must have 4 channels"); + free_apng(&apng); + } int n = apng.width * apng.height; std::vector iconData(n); @@ -462,6 +464,8 @@ void Platform::setWindowIcon(const std::string& pngIcon) SendMessage(win32.window, WM_SETICON, ICON_SMALL, (LPARAM)icon); SendMessage(win32.window, WM_SETICON, ICON_BIG, (LPARAM)icon); + + free_apng(&apng); } else logError("could not load app icon"); } diff --git a/src/framework/platform/x11platform.cpp b/src/framework/platform/x11platform.cpp index 8604007d..1bc5affa 100644 --- a/src/framework/platform/x11platform.cpp +++ b/src/framework/platform/x11platform.cpp @@ -704,8 +704,12 @@ void Platform::setWindowIcon(const std::string& pngIcon) std::stringstream fin; g_resources.loadFile(pngIcon, fin); if(load_apng(fin, &apng) == 0) { - if(apng.bpp != 4) + if(apng.bpp != 4) { logError("could not set app icon, icon image must have 4 channels"); + free_apng(&apng); + return; + } + int n = apng.width * apng.height; std::vector iconData(n + 2); iconData[0] = apng.width;