From 2a04862ca30d70897a28a9462a91532713926838 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Tue, 27 Feb 2018 00:58:20 +0100 Subject: [PATCH] Fix an issue where you could not give an absolute path to a theme. --- theme.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/theme.cpp b/theme.cpp index bb0bcaf..572efb1 100644 --- a/theme.cpp +++ b/theme.cpp @@ -1041,8 +1041,21 @@ Theme::Theme(const string &filename, const vector &search_dirs, Resource lua_settop(L, 0); vector errors; bool success = false; - for (size_t i = 0; i < search_dirs.size(); ++i) { - string path = search_dirs[i] + "/" + filename; + + vector real_search_dirs; + if (!filename.empty() && filename[0] == '/') { + real_search_dirs.push_back(""); + } else { + real_search_dirs = search_dirs; + } + + for (const string &dir : real_search_dirs) { + string path; + if (dir.empty()) { + path = filename; + } else { + path = dir + "/" + filename; + } int err = luaL_loadfile(L, path.c_str()); if (err == 0) { // Success; actually call the code. -- 2.39.2