From 5e2b8a50483daec83d1552cb7e0ce394113022b4 Mon Sep 17 00:00:00 2001 From: XinyuHou Date: Mon, 20 Apr 2015 16:16:53 +0100 Subject: [PATCH] Fixed #4537 by add file error checking --- src/gui/src/PluginManager.cpp | 17 ++++++++++++----- src/gui/src/PluginManager.h | 2 +- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/gui/src/PluginManager.cpp b/src/gui/src/PluginManager.cpp index 453fd869..863ce9c0 100644 --- a/src/gui/src/PluginManager.cpp +++ b/src/gui/src/PluginManager.cpp @@ -94,7 +94,10 @@ bool PluginManager::exist(QString name) void PluginManager::downloadPlugins() { if (m_DataDownloader.isFinished()) { - savePlugin(); + if (!savePlugin()) { + return; + } + if (m_DownloadIndex != m_PluginList.size() - 1) { emit downloadNext(); } @@ -173,7 +176,7 @@ void PluginManager::generateCertificate() downloadOpenSslSetup(); } -void PluginManager::savePlugin() +bool PluginManager::savePlugin() { // create the path if not exist QDir dir(m_PluginDir); @@ -189,15 +192,19 @@ void PluginManager::savePlugin() QFile file(filename); if (!file.open(QIODevice::WriteOnly)) { emit error( - tr("Failed to download '%1' plugin to: %2") + tr("Failed to download plugin '%1' to: %2 \n %3") .arg(m_PluginList.at(m_DownloadIndex)) - .arg(m_PluginDir)); + .arg(m_PluginDir) + .arg(file.errorString())); - return; + file.close(); + return false; } file.write(m_DataDownloader.data()); file.close(); + + return true; } QString PluginManager::getPluginUrl(const QString& pluginName) diff --git a/src/gui/src/PluginManager.h b/src/gui/src/PluginManager.h index 54cab017..e6e390e1 100644 --- a/src/gui/src/PluginManager.h +++ b/src/gui/src/PluginManager.h @@ -44,7 +44,7 @@ public slots: void doGenerateCertificate(); private: - void savePlugin(); + bool savePlugin(); QString getPluginUrl(const QString& pluginName); QString getOpenSslSetupUrl(); bool checkOpenSslBinary();