Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix update check for most up to date versions #8547

Merged
merged 2 commits into from Jul 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion rpcs3/rpcs3qt/main_window.cpp
Expand Up @@ -186,7 +186,7 @@ void main_window::Init()
QAction *download_action = new QAction(tr("Download Update"), download_menu);
connect(download_action, &QAction::triggered, this, [this]
{
m_updater.update(false);
m_updater.update();
});

download_menu->addAction(download_action);
Expand Down
25 changes: 11 additions & 14 deletions rpcs3/rpcs3qt/update_manager.cpp
Expand Up @@ -41,6 +41,8 @@ update_manager::update_manager()

void update_manager::check_for_updates(bool automatic, bool check_only, QWidget* parent)
{
m_update_message.clear();

#ifdef __linux__
if (automatic && !::getenv("APPIMAGE"))
{
Expand Down Expand Up @@ -75,7 +77,7 @@ void update_manager::check_for_updates(bool automatic, bool check_only, QWidget*
}
}

Q_EMIT signal_update_available(result_json);
Q_EMIT signal_update_available(result_json && !m_update_message.isEmpty());
});

const std::string url = "https://update.rpcs3.net/?api=v1&c=" + rpcs3::get_commit_and_hash().second;
Expand Down Expand Up @@ -199,29 +201,27 @@ bool update_manager::handle_json(bool automatic, bool check_only, const QByteArr
return true;
}

update(automatic);
update();
return true;
}

void update_manager::update(bool automatic)
void update_manager::update()
{
if (QMessageBox::question(m_downloader->get_progress_dialog(), tr("Update Available"), m_update_message, QMessageBox::Yes | QMessageBox::No) == QMessageBox::No)
if (m_update_message.isEmpty() ||
QMessageBox::question(m_downloader->get_progress_dialog(), tr("Update Available"), m_update_message, QMessageBox::Yes | QMessageBox::No) == QMessageBox::No)
{
m_downloader->close_progress_dialog();
return;
}

m_downloader->disconnect();

connect(m_downloader, &downloader::signal_download_error, this, [this, automatic](const QString& /*error*/)
connect(m_downloader, &downloader::signal_download_error, this, [this](const QString& /*error*/)
{
if (!automatic)
{
QMessageBox::warning(m_parent, tr("Auto-updater"), tr("An error occurred during the auto-updating process.\nCheck the log for more information."));
}
QMessageBox::warning(m_parent, tr("Auto-updater"), tr("An error occurred during the auto-updating process.\nCheck the log for more information."));
});

connect(m_downloader, &downloader::signal_download_finished, this, [this, automatic](const QByteArray& data)
connect(m_downloader, &downloader::signal_download_finished, this, [this](const QByteArray& data)
{
const bool result_json = handle_rpcs3(data);

Expand All @@ -230,10 +230,7 @@ void update_manager::update(bool automatic)
// The progress dialog is configured to stay open, so we need to close it manually if the download succeeds.
m_downloader->close_progress_dialog();

if (!automatic)
{
QMessageBox::warning(m_parent, tr("Auto-updater"), tr("An error occurred during the auto-updating process.\nCheck the log for more information."));
}
QMessageBox::warning(m_parent, tr("Auto-updater"), tr("An error occurred during the auto-updating process.\nCheck the log for more information."));
}

Q_EMIT signal_update_available(false);
Expand Down
3 changes: 2 additions & 1 deletion rpcs3/rpcs3qt/update_manager.h
Expand Up @@ -14,6 +14,7 @@ class update_manager final : public QObject
downloader* m_downloader = nullptr;
QWidget* m_parent = nullptr;

// This message is empty if there is no download available
QString m_update_message;

std::string m_request_url;
Expand All @@ -26,7 +27,7 @@ class update_manager final : public QObject
public:
update_manager();
void check_for_updates(bool automatic, bool check_only, QWidget* parent = nullptr);
void update(bool automatic);
void update();

Q_SIGNALS:
void signal_update_available(bool update_available);
Expand Down