From fc8a6b358fb7bda18979c7c5c23c13d7c2ae8dc8 Mon Sep 17 00:00:00 2001 From: LostDragonist Date: Fri, 20 Jul 2018 03:21:30 -0500 Subject: Improve robustness of endorsement checks At times, the voted_by_user item is returned as Invalid. toBool() causes this to be false, meaning the item is seen as not endorsed. Now, the endorsement state is not checked if the data is invalid. --- src/mainwindow.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index c9874b20..d8dd6e45 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -4388,7 +4388,8 @@ void MainWindow::nxmUpdatesAvailable(const std::vector &modIDs, QVariant us if (game && result["id"].toInt() == game->nexusModOrganizerID() && result["game_id"].toInt() == game->nexusGameID()) { - if (!result["voted_by_user"].toBool()) { + if (result["voted_by_user"].type() != QVariant::Invalid && + !result["voted_by_user"].toBool()) { ui->actionEndorseMO->setVisible(true); } } else { @@ -4412,7 +4413,8 @@ void MainWindow::nxmUpdatesAvailable(const std::vector &modIDs, QVariant us (*iter)->setNewestVersion(result["version"].toString()); (*iter)->setNexusDescription(result["description"].toString()); if (NexusInterface::instance(&m_PluginContainer)->getAccessManager()->loggedIn() && - result.contains("voted_by_user")) { + result.contains("voted_by_user") && + result["voted_by_user"].type() != QVariant::Invalid) { // don't use endorsement info if we're not logged in or if the response doesn't contain it (*iter)->setIsEndorsed(result["voted_by_user"].toBool()); } -- cgit v1.3.1