Avoid race conditions when saving downloaded files

This commit is contained in:
Alex Spataru 2015-01-26 01:02:53 -06:00
parent 9164a5fd92
commit b79ffc3d42
5 changed files with 7 additions and 43 deletions

View File

@ -16,6 +16,8 @@
#include "download_dialog.h"
#include "ui_download_dialog.h"
#include <QMutex>
DownloadDialog::DownloadDialog (QWidget *parent)
: QWidget (parent)
, ui (new Ui::DownloadDialog)
@ -150,14 +152,17 @@ void DownloadDialog::downloadFinished (void)
{
QStringList list = m_reply->url().toString().split ("/");
QFile file (QDir::tempPath() + "/" + list.at (list.count() - 1));
QMutex _mutex;
if (file.open (QIODevice::WriteOnly))
{
_mutex.lock();
file.write (data);
m_path = file.fileName();
file.close();
_mutex.unlock();
}
file.close();
installUpdate();
}
}

View File

@ -102,7 +102,7 @@ QSimpleUpdater::QSimpleUpdater (QObject *parent)
connect (m_progressDialog, SIGNAL (cancelClicked()), this, SLOT (cancel()));
connect (this, SIGNAL (checkingFinished()), this, SLOT (onCheckingFinished()));
setApplicationVersion (qApp->applicationVersion());
}

View File

@ -1,21 +0,0 @@
:: Description: This script changes the style format of
:: all the source code of the project.
:: Setup the command line
@echo off
title Autostyle
:: Go to the directory where the script is run
cd /d %~dp0
:: Style and format the source code recursively
astyle --style=allman -C -S -xG -Y -XW -w -f -F -p -xd -k3 -y -xj -c -K -L --suffix=none --recursive ../*.cpp ../*.h ../*.hxx ../*.cxx
:: Notify the user that we have finished
echo.
echo Code styling complete!
echo.
:: Let the user see the output
pause

View File

@ -1,19 +0,0 @@
#!/bin/bash
# Description: This script changes the style format of
# all the source code of the project.
# Run only on the directory of the script
cd "$(dirname ${BASH_SOURCE[0]})"
# Style and format recursively
astyle --style=allman -C -S -xG -Y -XW -w -f -F -p -xd -k3 -y -xj -c -K -L --suffix=none --recursive ../*.cpp ../*.h ../*.hxx ../*.cxx
# Notify the user that we are done
echo
echo "Code styling complete!"
echo
# Let the user see the output
read -n1 -r -p "Press any key to continue..." key
clear

View File

@ -1 +0,0 @@
The scripts contained in this folder will require you to install the [astyle](http://astyle.sf.net) source code styler.