From a8aae7379bd01b72bdbc6e4f415c5dc4d163b43d Mon Sep 17 00:00:00 2001 From: StackZ <47382115+SuperSaiyajinStackZ@users.noreply.github.com> Date: Wed, 23 Dec 2020 12:53:03 +0100 Subject: [PATCH] Cancel Shortcut creation if Name == "". --- source/store/downList.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/source/store/downList.cpp b/source/store/downList.cpp index 64b23e1..fbe3fdd 100644 --- a/source/store/downList.cpp +++ b/source/store/downList.cpp @@ -54,9 +54,9 @@ static const std::vector downloadBoxes = { const std::string &unistoreName: The name of the UniStore filename. const std::string &author: The author of the app. */ -static void CreateShortcut(const std::string &entryName, int index, const std::string &unistoreName, const std::string &author) { +static bool CreateShortcut(const std::string &entryName, int index, const std::string &unistoreName, const std::string &author) { std::string sName = Input::setkbdString(30, Lang::get("ENTER_SHORTCUT_FILENAME"), {}); - if (sName == "") sName = "tmp"; + if (sName == "") return false; // Just cancel. std::ofstream out(config->shortcut() + "/" + sName + ".xml", std::ios::binary); out << "" << std::endl; @@ -82,6 +82,7 @@ static void CreateShortcut(const std::string &entryName, int index, const std::s out << " " << author << "" << std::endl; out << "" << std::endl; out.close(); + return true; } @@ -162,8 +163,9 @@ void StoreUtils::DownloadHandle(const std::unique_ptr &store, const std:: if (entries.size() <= 0) return; // Smaller than 0 -> No No. if (Msg::promptMsg(Lang::get("CREATE_SHORTCUT"))) { - CreateShortcut(entry->GetTitle(), store->GetDownloadIndex(), store->GetFileName(), entry->GetAuthor()); - Msg::waitMsg(Lang::get("SHORTCUT_CREATED")); + if (CreateShortcut(entry->GetTitle(), store->GetDownloadIndex(), store->GetFileName(), entry->GetAuthor())) { + Msg::waitMsg(Lang::get("SHORTCUT_CREATED")); + } } } }