From 1b1b76ee70a2d4a7d498eeb21873dac05163f234 Mon Sep 17 00:00:00 2001 From: ck <qt-info@nokia.com> Date: Tue, 12 Jan 2010 14:58:48 +0100 Subject: [PATCH] Maemo: Get rid of MSVC compiler warning. --- .../qt-maemo/maemosshconnection.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemosshconnection.cpp b/src/plugins/qt4projectmanager/qt-maemo/maemosshconnection.cpp index def3119a3f6..1ad9d2b8681 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemosshconnection.cpp +++ b/src/plugins/qt4projectmanager/qt-maemo/maemosshconnection.cpp @@ -159,16 +159,25 @@ MaemoSftpConnection::~MaemoSftpConnection() } +class FileManager +{ +public: + FileManager(const QString &filePath) + : m_file(fopen(filePath.toLatin1().data(), "rb")) {} + ~FileManager() { if (m_file) fclose(m_file); } + FILE *file() const { return m_file; } +private: + FILE * const m_file; +}; + void MaemoSftpConnection::transferFiles(const QList<SshDeploySpec> &deploySpecs) { for (int i = 0; i < deploySpecs.count(); ++i) { const SshDeploySpec &deploySpec = deploySpecs.at(i); const QString &curSrcFile = deploySpec.srcFilePath(); - QSharedPointer<FILE> filePtr(fopen(curSrcFile.toLatin1().data(), "rb"), - &std::fclose); - if (filePtr.isNull()) + FileManager fileMgr(curSrcFile); + if (!fileMgr.file()) throw MaemoSshException(tr("Could not open file '%1'").arg(curSrcFile)); - const QString &curTgtFile = deploySpec.tgtFilePath(); // TODO: Is the mkdir() method recursive? If not, we have to @@ -180,7 +189,7 @@ void MaemoSftpConnection::transferFiles(const QList<SshDeploySpec> &deploySpecs) qDebug("Deploying file %s to %s.", qPrintable(curSrcFile), qPrintable(curTgtFile)); - if (!sftp->put(filePtr.data(), curTgtFile.toLatin1().data())) { + if (!sftp->put(fileMgr.file(), curTgtFile.toLatin1().data())) { const QString &error = tr("Could not copy local file '%1' " "to remote file '%2': %3").arg(curSrcFile, curTgtFile) .arg(lastError()); -- GitLab