From 44a25d6b4feef3bf134622defc349adb1b177d2f Mon Sep 17 00:00:00 2001 From: TangoCash Date: Fri, 29 Oct 2021 19:33:33 +0200 Subject: [PATCH] supplemental 2 to 731e09cd5e4f57cdd9c5714d23fbece7b6f75903 Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/26e1bbc426b2c408871ed800a28ca6498a6fceba Author: TangoCash Date: 2021-10-29 (Fri, 29 Oct 2021) --- src/driver/fb_generic.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/driver/fb_generic.cpp b/src/driver/fb_generic.cpp index 4f86016e6..c24ab3cfe 100644 --- a/src/driver/fb_generic.cpp +++ b/src/driver/fb_generic.cpp @@ -698,15 +698,19 @@ void CFrameBuffer::setIconBasePath(const std::string & iconPath) std::string CFrameBuffer::getIconPath(std::string icon_name, std::string file_type) { + // why search when we have an absolut path ? + if (icon_name.find("/", 0) != std::string::npos) + return icon_name; + std::vector filetypes = { ".svg", ".png", ".jpg" }; - std::string path, filetype = ""; + std::string path = icon_name; std::string::size_type pos = icon_name.find_last_of("."); if (pos != std::string::npos && file_type.empty()) if (std::find(filetypes.begin(), filetypes.end(), icon_name.substr(pos)) != filetypes.end()) { - icon_name = icon_name.substr(0,pos); - file_type = icon_name.substr(pos+1); + icon_name = path.substr(0,pos); + file_type = path.substr(pos+1); } if (!file_type.empty()) { @@ -734,10 +738,8 @@ std::string CFrameBuffer::getIconPath(std::string icon_name, std::string file_ty } } - if (icon_name.find("/", 0) != std::string::npos) - path = icon_name; - - return path; + // nothing found, return empty string + return ""; } void CFrameBuffer::getIconSize(const char * const filename, int* width, int *height)