Avoid race conditions when saving downloaded files
This commit is contained in:
parent
9164a5fd92
commit
b79ffc3d42
@ -16,6 +16,8 @@
|
|||||||
#include "download_dialog.h"
|
#include "download_dialog.h"
|
||||||
#include "ui_download_dialog.h"
|
#include "ui_download_dialog.h"
|
||||||
|
|
||||||
|
#include <QMutex>
|
||||||
|
|
||||||
DownloadDialog::DownloadDialog (QWidget *parent)
|
DownloadDialog::DownloadDialog (QWidget *parent)
|
||||||
: QWidget (parent)
|
: QWidget (parent)
|
||||||
, ui (new Ui::DownloadDialog)
|
, ui (new Ui::DownloadDialog)
|
||||||
@ -150,14 +152,17 @@ void DownloadDialog::downloadFinished (void)
|
|||||||
{
|
{
|
||||||
QStringList list = m_reply->url().toString().split ("/");
|
QStringList list = m_reply->url().toString().split ("/");
|
||||||
QFile file (QDir::tempPath() + "/" + list.at (list.count() - 1));
|
QFile file (QDir::tempPath() + "/" + list.at (list.count() - 1));
|
||||||
|
QMutex _mutex;
|
||||||
|
|
||||||
if (file.open (QIODevice::WriteOnly))
|
if (file.open (QIODevice::WriteOnly))
|
||||||
{
|
{
|
||||||
|
_mutex.lock();
|
||||||
file.write (data);
|
file.write (data);
|
||||||
m_path = file.fileName();
|
m_path = file.fileName();
|
||||||
|
file.close();
|
||||||
|
_mutex.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
file.close();
|
|
||||||
installUpdate();
|
installUpdate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -102,7 +102,7 @@ QSimpleUpdater::QSimpleUpdater (QObject *parent)
|
|||||||
|
|
||||||
connect (m_progressDialog, SIGNAL (cancelClicked()), this, SLOT (cancel()));
|
connect (m_progressDialog, SIGNAL (cancelClicked()), this, SLOT (cancel()));
|
||||||
connect (this, SIGNAL (checkingFinished()), this, SLOT (onCheckingFinished()));
|
connect (this, SIGNAL (checkingFinished()), this, SLOT (onCheckingFinished()));
|
||||||
|
|
||||||
setApplicationVersion (qApp->applicationVersion());
|
setApplicationVersion (qApp->applicationVersion());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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
|
|
||||||
|
|
@ -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
|
|
@ -1 +0,0 @@
|
|||||||
The scripts contained in this folder will require you to install the [astyle](http://astyle.sf.net) source code styler.
|
|
Loading…
Reference in New Issue
Block a user