From a0d47bf1674849464e77b0dbff291d176632e19d Mon Sep 17 00:00:00 2001 From: bubnikv Date: Fri, 20 Dec 2019 17:29:23 +0100 Subject: [PATCH] Fixed a file handle leak. --- src/slic3r/GUI/wxExtensions.cpp | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/slic3r/GUI/wxExtensions.cpp b/src/slic3r/GUI/wxExtensions.cpp index 7c63e96c6..ad74e0ea0 100644 --- a/src/slic3r/GUI/wxExtensions.cpp +++ b/src/slic3r/GUI/wxExtensions.cpp @@ -433,17 +433,15 @@ static std::string icon_name_respected_to_mode(const std::string& bmp_name_in) #else const std::string folder = "white/"; #endif - std::string bmp_name = Slic3r::GUI::wxGetApp().dark_mode() ? folder + bmp_name_in : bmp_name_in; - boost::replace_last(bmp_name, ".png", ""); - FILE* fp = NULL; - fp = boost::nowide::fopen(Slic3r::var(bmp_name + ".svg").c_str(), "rb"); - if (!fp) - { - bmp_name = bmp_name_in; - boost::replace_last(bmp_name, ".png", ""); - if (fp) fclose(fp); - } - + std::string bmp_name; + if (Slic3r::GUI::wxGetApp().dark_mode()) { + bmp_name = folder + bmp_name_in; + boost::replace_last(bmp_name, ".png", ""); + } + if (bmp_name.empty()) { + bmp_name = bmp_name_in; + boost::replace_last(bmp_name, ".png", ""); + } return bmp_name; }