From 0234a70bfdc0edb58d4edf02419ae8eae44f9b91 Mon Sep 17 00:00:00 2001 From: RickyRister <42636155+RickyRister@users.noreply.github.com> Date: Mon, 23 Dec 2024 17:39:57 -0800 Subject: [PATCH] fix bug with uploading unnamed decks ignoring the prompt (#5313) --- cockatrice/src/client/tabs/tab_deck_storage.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/cockatrice/src/client/tabs/tab_deck_storage.cpp b/cockatrice/src/client/tabs/tab_deck_storage.cpp index 8ab91e2be..afe752159 100644 --- a/cockatrice/src/client/tabs/tab_deck_storage.cpp +++ b/cockatrice/src/client/tabs/tab_deck_storage.cpp @@ -176,14 +176,8 @@ void TabDeckStorage::actUpload() QFile deckFile(filePath); QFileInfo deckFileInfo(deckFile); - QString deckString; DeckLoader deck; - bool error = !deck.loadFromFile(filePath, DeckLoader::CockatriceFormat); - if (!error) { - deckString = deck.writeToString_Native(); - error = deckString.length() > MAX_FILE_LENGTH; - } - if (error) { + if (!deck.loadFromFile(filePath, DeckLoader::CockatriceFormat)) { QMessageBox::critical(this, tr("Error"), tr("Invalid deck file")); return; } @@ -202,6 +196,12 @@ void TabDeckStorage::actUpload() deck.setName(deck.getName().left(MAX_NAME_LENGTH)); } + QString deckString = deck.writeToString_Native(); + if (deckString.length() > MAX_FILE_LENGTH) { + QMessageBox::critical(this, tr("Error"), tr("Invalid deck file")); + return; + } + Command_DeckUpload cmd; cmd.set_path(targetPath.toStdString()); cmd.set_deck_list(deckString.toStdString());