Handle return value of QFile::open
This commit is contained in:
+4
-2
@@ -15,11 +15,13 @@ About::About(QWidget *parent) : QDialog(parent)
|
|||||||
QLabel *label = new QLabel(this);
|
QLabel *label = new QLabel(this);
|
||||||
|
|
||||||
QFile tenmonText(":/about/tenmon");
|
QFile tenmonText(":/about/tenmon");
|
||||||
tenmonText.open(QIODevice::ReadOnly);
|
if(tenmonText.open(QIODevice::ReadOnly))
|
||||||
|
{
|
||||||
QByteArray text = tenmonText.readAll();
|
QByteArray text = tenmonText.readAll();
|
||||||
text.replace("@GITVERSION@", GITVERSION);
|
text.replace("@GITVERSION@", GITVERSION);
|
||||||
label->setText(text);
|
label->setText(text);
|
||||||
label->setOpenExternalLinks(true);
|
label->setOpenExternalLinks(true);
|
||||||
|
}
|
||||||
|
|
||||||
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok);
|
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok);
|
||||||
connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
|
connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
|
||||||
@@ -41,7 +43,7 @@ HelpDialog::HelpDialog(QWidget *parent) : QDialog(parent)
|
|||||||
layout->addWidget(helpText);
|
layout->addWidget(helpText);
|
||||||
|
|
||||||
QFile tenmonText(":/help");
|
QFile tenmonText(":/help");
|
||||||
tenmonText.open(QIODevice::ReadOnly);
|
if(tenmonText.open(QIODevice::ReadOnly))
|
||||||
helpText->setHtml(tenmonText.readAll());
|
helpText->setHtml(tenmonText.readAll());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -345,17 +345,21 @@ Download::Download(QNetworkReply *reply, const QString indexPath, QObject *paren
|
|||||||
filename.remove(QRegularExpression("\\.zst$"));
|
filename.remove(QRegularExpression("\\.zst$"));
|
||||||
|
|
||||||
_fw.setFileName(indexPath + "/" + filename);
|
_fw.setFileName(indexPath + "/" + filename);
|
||||||
_fw.open(QIODevice::WriteOnly | QIODevice::Truncate);
|
if(_fw.open(QIODevice::WriteOnly | QIODevice::Truncate))
|
||||||
if(_fw.isOpen())
|
|
||||||
{
|
{
|
||||||
qDebug() << "open file" << _fw.fileName();
|
qDebug() << "open file" << _fw.fileName();
|
||||||
}
|
|
||||||
|
|
||||||
_dstream = ZSTD_createDStream();
|
_dstream = ZSTD_createDStream();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qWarning() << "Failed to open file" << _fw.fileName();
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Download::~Download()
|
Download::~Download()
|
||||||
{
|
{
|
||||||
|
if(_dstream)
|
||||||
ZSTD_freeDStream(_dstream);
|
ZSTD_freeDStream(_dstream);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -402,7 +406,7 @@ void Download::finished()
|
|||||||
|
|
||||||
void Download::decompress(QByteArray &data)
|
void Download::decompress(QByteArray &data)
|
||||||
{
|
{
|
||||||
if(data.isEmpty())return;
|
if(data.isEmpty() || _dstream == nullptr)return;
|
||||||
|
|
||||||
_hash.addData(data);
|
_hash.addData(data);
|
||||||
|
|
||||||
|
|||||||
@@ -11,8 +11,8 @@
|
|||||||
class Download : public QObject
|
class Download : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
QNetworkReply *_reply;
|
QNetworkReply *_reply = nullptr;
|
||||||
ZSTD_DStream *_dstream;
|
ZSTD_DStream *_dstream = nullptr;
|
||||||
QFile _fw;
|
QFile _fw;
|
||||||
QCryptographicHash _hash;
|
QCryptographicHash _hash;
|
||||||
public:
|
public:
|
||||||
|
|||||||
Reference in New Issue
Block a user