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