Merge pull request #7213 from Techjar/netplay-fix-md5

Qt/MD5Dialog: Fix checksum result comparison
This commit is contained in:
spycrab 2018-07-05 22:45:54 +02:00 committed by GitHub
commit 233787e8a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 12 deletions

View File

@ -4,6 +4,9 @@
#include "DolphinQt2/NetPlay/MD5Dialog.h" #include "DolphinQt2/NetPlay/MD5Dialog.h"
#include <algorithm>
#include <functional>
#include <QDialogButtonBox> #include <QDialogButtonBox>
#include <QGroupBox> #include <QGroupBox>
#include <QLabel> #include <QLabel>
@ -73,6 +76,8 @@ void MD5Dialog::show(const QString& title)
m_progress_bars.clear(); m_progress_bars.clear();
m_status_labels.clear(); m_status_labels.clear();
m_results.clear();
m_check_label->setText(QString::fromStdString(""));
for (const auto* player : Settings::Instance().GetNetPlayClient()->GetPlayers()) for (const auto* player : Settings::Instance().GetNetPlayClient()->GetPlayers())
{ {
@ -83,8 +88,6 @@ void MD5Dialog::show(const QString& title)
m_progress_layout->addWidget(m_status_labels[player->pid]); m_progress_layout->addWidget(m_status_labels[player->pid]);
} }
m_last_result = "";
QDialog::show(); QDialog::show();
} }
@ -110,18 +113,20 @@ void MD5Dialog::SetResult(int pid, const std::string& result)
m_status_labels[pid]->setText( m_status_labels[pid]->setText(
tr("%1[%2]: %3").arg(player_name, QString::number(pid), QString::fromStdString(result))); tr("%1[%2]: %3").arg(player_name, QString::number(pid), QString::fromStdString(result)));
if (m_last_result.empty()) m_results.push_back(result);
if (m_results.size() >= Settings::Instance().GetNetPlayClient()->GetPlayers().size())
{
if (std::adjacent_find(m_results.begin(), m_results.end(), std::not_equal_to<>()) ==
m_results.end())
{ {
m_check_label->setText(tr("The hashes match!")); m_check_label->setText(tr("The hashes match!"));
return;
} }
else
if (m_last_result != result)
{ {
m_check_label->setText(tr("The hashes do not match!")); m_check_label->setText(tr("The hashes do not match!"));
} }
}
m_last_result = result;
} }
void MD5Dialog::reject() void MD5Dialog::reject()

View File

@ -4,6 +4,10 @@
#pragma once #pragma once
#include <map>
#include <string>
#include <vector>
#include <QDialog> #include <QDialog>
class QDialogButtonBox; class QDialogButtonBox;
@ -32,7 +36,7 @@ private:
std::map<int, QProgressBar*> m_progress_bars; std::map<int, QProgressBar*> m_progress_bars;
std::map<int, QLabel*> m_status_labels; std::map<int, QLabel*> m_status_labels;
std::string m_last_result; std::vector<std::string> m_results;
QGroupBox* m_progress_box; QGroupBox* m_progress_box;
QVBoxLayout* m_progress_layout; QVBoxLayout* m_progress_layout;