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 #1195 check for updates failure #1413

Merged
merged 3 commits into from
Aug 6, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 31 additions & 4 deletions app/src/checkupdatesdialog.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "checkupdatesdialog.h"
#include "checkupdatesdialog.h"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this intentional? Back in #683, you yourself said no BOM was preferable for better cross-platform compatibility. Seen this on a bunch of your commits lately.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Damn it, must be my editor. I will remove the BOM

#include <QNetworkReply>
#include <QNetworkAccessManager>
#include <QHBoxLayout>
Expand Down Expand Up @@ -78,7 +78,7 @@ void CheckUpdatesDialog::startChecking()
void CheckUpdatesDialog::regularBuildCheck()
{
mNetworkManager = new QNetworkAccessManager(this);
QUrl url("http://github.com/pencil2d/pencil/releases.atom");
QUrl url("https://github.com/pencil2d/pencil/releases.atom");

QNetworkRequest req;
req.setUrl(url);
Expand Down Expand Up @@ -108,6 +108,24 @@ void CheckUpdatesDialog::networkErrorHappened()
mDownloadButton->setEnabled(false);
}

void CheckUpdatesDialog::networkResponseIsEmpty()
{
mTitleLabel->setText(tr("<b>An error occurred while checking for updates</b>", "error msg of check-for-update"));
mDetailLabel->setText(tr("Network response is empty", "error msg of check-for-update"));
mProgressBar->setRange(0, 1);
mProgressBar->setValue(1);
mDownloadButton->setEnabled(false);
}

void CheckUpdatesDialog::invalidReleaseXml()
{
mTitleLabel->setText(tr("<b>An error occurred while checking for updates</b>", "error msg of check-for-update"));
mDetailLabel->setText(tr("Couldn't retrieve the version information", "error msg of check-for-update"));
mProgressBar->setRange(0, 1);
mProgressBar->setValue(1);
mDownloadButton->setEnabled(false);
}

void CheckUpdatesDialog::networkRequestFinished(QNetworkReply* reply)
{
reply->deleteLater();
Expand All @@ -122,9 +140,18 @@ void CheckUpdatesDialog::networkRequestFinished(QNetworkReply* reply)
}

auto releasesAtom = QString::fromUtf8(reply->readAll()).trimmed();
//qDebug() << releasesAtom;
if (releasesAtom.isEmpty())
{
networkResponseIsEmpty();
return;
}

QString latestVersionString = getVersionNumberFromXml(releasesAtom);
if (latestVersionString == "0.0.1")
{
invalidReleaseXml();
return;
}

bool isNewVersionAvailable = compareVersion(APP_VERSION, latestVersionString);
if (isNewVersionAvailable)
Expand Down Expand Up @@ -153,7 +180,7 @@ bool CheckUpdatesDialog::compareVersion(QString currentVersion, QString latestVe

QString CheckUpdatesDialog::getVersionNumberFromXml(QString xml)
{
// XML source: http://github.com/pencil2d/pencil/releases.atom
// XML source: https://github.com/pencil2d/pencil/releases.atom

QXmlStreamReader xmlReader(xml);

Expand Down
4 changes: 3 additions & 1 deletion app/src/checkupdatesdialog.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#ifndef CHECKUPDATESDIALOG_H
#ifndef CHECKUPDATESDIALOG_H
#define CHECKUPDATESDIALOG_H

#include <QDialog>
Expand All @@ -24,6 +24,8 @@ class CheckUpdatesDialog : public QDialog
void regularBuildCheck();
void nightlyBuildCheck();
void networkErrorHappened();
void networkResponseIsEmpty();
void invalidReleaseXml();

void networkRequestFinished(QNetworkReply* reply);
bool compareVersion(QString currentVersion, QString latestVersion);
Expand Down
20 changes: 18 additions & 2 deletions util/after-build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,18 @@ $arch = switch ($platform) {
default {"Unknown"; break}
}

$libcrypto = switch ($platform) {
"x86" {"C:\OpenSSL-v111-Win32\bin\libcrypto-1_1.dll"; break}
"amd64" {"C:\OpenSSL-v111-Win64\bin\libcrypto-1_1-x64.dll"; break}
default {""; break}
}

$libssl = switch ($platform) {
"x86" {"C:\OpenSSL-v111-Win32\bin\libssl-1_1.dll"; break}
"amd64" {"C:\OpenSSL-v111-Win64\bin\libssl-1_1-x64.dll"; break}
default {""; break}
}

[string]$ffmpegFileName = "ffmpeg-4.1.1-$arch-static"
[string]$ffmpegUrl = "https://ffmpeg.zeranoe.com/builds/$arch/static/$ffmpegFileName.zip"

Expand Down Expand Up @@ -43,15 +55,19 @@ Remove-Item -Path "./$ffmpegFileName" -Recurse

Remove-Item -Path "./Pencil2D" -Recurse -ErrorAction SilentlyContinue
Copy-Item -Path "./bin" -Destination "./Pencil2D" -Recurse
Remove-Item -Path "./Pencil2D/*.pdb"
Remove-Item -Path "./Pencil2D/*.ilk"

echo ">>> Deploying Qt libraries"

& "windeployqt" @("Pencil2D/pencil2d.exe")

echo ">>> Copy OpenSSL DLLs"
Copy-Item $libcrypto -Destination "./Pencil2D"
Copy-Item $libssl -Destination "./Pencil2D"

echo ">>> Zipping bin folder"

Remove-Item -Path "./Pencil2D/*.pdb"
Remove-Item -Path "./Pencil2D/*.ilk"
Compress-Archive -Path "./Pencil2D" -DestinationPath "./Pencil2D.zip"

$today = Get-Date -Format "yyyy-MM-dd"
Expand Down