From 4009d24e7305963efa9ada38a8bd1fc2f87e7ffc Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Tue, 18 Oct 2011 00:10:02 +0000 Subject: [PATCH] Return an approriately-sized empty icon from icon::get if no icon exists Originally committed to SVN as r5756. --- aegisub/src/command/icon.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/aegisub/src/command/icon.cpp b/aegisub/src/command/icon.cpp index dbfc86564..f6fb27f58 100644 --- a/aegisub/src/command/icon.cpp +++ b/aegisub/src/command/icon.cpp @@ -41,21 +41,31 @@ iconMap icon24; wxBitmap const& get(std::string const& name, const int size) { // XXX: This code will go away with dynamic icon generation so I'm not // concerned about it. + iconMap::iterator index; if (size != 24) { - iconMap::iterator index; if ((index = icon16.find(name)) != icon16.end()) return index->second; } else { - iconMap::iterator index; if ((index = icon24.find(name)) != icon24.end()) return index->second; } LOG_W("icon/get") << "Icon not found: " << name << " " << size; - static wxBitmap empty; - return empty; + static wxBitmap empty16(16, 16, 1); + static wxBitmap empty24(24, 24, 1); + static bool initialized = false; + + if (!initialized) { + empty16.SetMask(new wxMask(empty16)); + empty24.SetMask(new wxMask(empty24)); + initialized = true; + } + + if (size != 24) + return empty16; + return empty24; }