mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 13:59:52 +08:00
MdEditor: close the temporary file explicitly after writing
This commit is contained in:
parent
61909c2c5d
commit
dc9c9f6bbd
@ -17,7 +17,8 @@ void VDownloader::handleDownloadFinished(QNetworkReply *reply)
|
||||
|
||||
data = reply->readAll();
|
||||
reply->deleteLater();
|
||||
emit downloadFinished(data, reply->url().toString());
|
||||
// The url() of the reply may be redirected and different from that of the request.
|
||||
emit downloadFinished(data, reply->request().url().toString());
|
||||
}
|
||||
|
||||
static QNetworkRequest networkRequest(const QUrl &p_url)
|
||||
|
@ -18,6 +18,7 @@ public:
|
||||
static QByteArray downloadSync(const QUrl &p_url);
|
||||
|
||||
signals:
|
||||
// Url is the original url of the request.
|
||||
void downloadFinished(const QByteArray &data, const QString &url);
|
||||
|
||||
private slots:
|
||||
|
@ -1719,6 +1719,7 @@ void VMdEditor::exportGraphAndCopy(const QString &p_lang,
|
||||
}
|
||||
|
||||
if (out.isEmpty() || m_exportTempFile->write(out) == -1) {
|
||||
m_exportTempFile->close();
|
||||
VUtils::showMessage(QMessageBox::Warning,
|
||||
tr("Warning"),
|
||||
tr("Fail to export graph."),
|
||||
@ -1727,8 +1728,11 @@ void VMdEditor::exportGraphAndCopy(const QString &p_lang,
|
||||
QMessageBox::Ok,
|
||||
this);
|
||||
} else {
|
||||
m_exportTempFile->close();
|
||||
|
||||
QClipboard *clipboard = QApplication::clipboard();
|
||||
clipboard->clear();
|
||||
|
||||
QImage img;
|
||||
img.loadFromData(out, p_format.toLocal8Bit().data());
|
||||
if (!img.isNull()) {
|
||||
@ -1741,8 +1745,6 @@ void VMdEditor::exportGraphAndCopy(const QString &p_lang,
|
||||
emit m_object->statusMessage(tr("Fail to read exported image: %1").arg(filePath));
|
||||
}
|
||||
}
|
||||
|
||||
m_exportTempFile->close();
|
||||
}
|
||||
|
||||
void VMdEditor::parseAndPaste()
|
||||
@ -2064,6 +2066,9 @@ void VMdEditor::replaceTextWithLocalImages(QString &p_text)
|
||||
if (tmpFile->open() && tmpFile->write(data) > -1) {
|
||||
srcImagePath = tmpFile->fileName();
|
||||
}
|
||||
|
||||
// Need to close it explicitly to flush cache of small file.
|
||||
tmpFile->close();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -59,7 +59,6 @@ void VPreviewManager::imageDownloaded(const QByteArray &p_data, const QString &p
|
||||
|
||||
QPixmap image;
|
||||
image.loadFromData(p_data);
|
||||
|
||||
if (!image.isNull()) {
|
||||
m_editor->addImage(name, image);
|
||||
emit requestUpdateImageLinks();
|
||||
|
Loading…
x
Reference in New Issue
Block a user