Permalink
Browse files

Qt/MD5Dialog: Fix checksum result comparison

  • Loading branch information...
Techjar committed Jul 5, 2018
1 parent fd83937 commit f3e2d98fddce8cf9ce75554d29929635cf4a1a3f
Showing with 21 additions and 12 deletions.
  1. +16 −11 Source/Core/DolphinQt2/NetPlay/MD5Dialog.cpp
  2. +5 −1 Source/Core/DolphinQt2/NetPlay/MD5Dialog.h
@@ -4,6 +4,9 @@
#include "DolphinQt2/NetPlay/MD5Dialog.h"
#include <algorithm>
#include <functional>
#include <QDialogButtonBox>
#include <QGroupBox>
#include <QLabel>
@@ -73,6 +76,8 @@ void MD5Dialog::show(const QString& title)
m_progress_bars.clear();
m_status_labels.clear();
m_results.clear();
m_check_label->setText(QString::fromStdString(""));
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_last_result = "";
QDialog::show();
}
@@ -110,18 +113,20 @@ void MD5Dialog::SetResult(int pid, const std::string& result)
m_status_labels[pid]->setText(
tr("%1[%2]: %3").arg(player_name, QString::number(pid), QString::fromStdString(result)));
if (m_last_result.empty())
{
m_check_label->setText(tr("The hashes match!"));
return;
}
m_results.push_back(result);
if (m_last_result != result)
if (m_results.size() >= Settings::Instance().GetNetPlayClient()->GetPlayers().size())
{
m_check_label->setText(tr("The hashes do not match!"));
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!"));
}
else
{
m_check_label->setText(tr("The hashes do not match!"));
}
}
m_last_result = result;
}
void MD5Dialog::reject()
@@ -4,6 +4,10 @@
#pragma once
#include <map>
#include <string>
#include <vector>
#include <QDialog>
class QDialogButtonBox;
@@ -32,7 +36,7 @@ class MD5Dialog : public QDialog
std::map<int, QProgressBar*> m_progress_bars;
std::map<int, QLabel*> m_status_labels;
std::string m_last_result;
std::vector<std::string> m_results;
QGroupBox* m_progress_box;
QVBoxLayout* m_progress_layout;

0 comments on commit f3e2d98

Please sign in to comment.