Small code clean-up.
This commit is contained in:
parent
ab3c1d5b02
commit
a663834cd8
@ -35,7 +35,7 @@
|
|||||||
#define VER_LAMEXP_MINOR_LO 1
|
#define VER_LAMEXP_MINOR_LO 1
|
||||||
#define VER_LAMEXP_TYPE RC
|
#define VER_LAMEXP_TYPE RC
|
||||||
#define VER_LAMEXP_PATCH 4
|
#define VER_LAMEXP_PATCH 4
|
||||||
#define VER_LAMEXP_BUILD 1694
|
#define VER_LAMEXP_BUILD 1696
|
||||||
#define VER_LAMEXP_CONFG 1558
|
#define VER_LAMEXP_CONFG 1558
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -54,9 +54,11 @@
|
|||||||
static const bool g_useFileDescrForQFile = false;
|
static const bool g_useFileDescrForQFile = false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define VALID_HANDLE(H) (((H) != NULL) && ((H) != INVALID_HANDLE_VALUE))
|
||||||
|
|
||||||
static void CLOSE_HANDLE(HANDLE &h)
|
static void CLOSE_HANDLE(HANDLE &h)
|
||||||
{
|
{
|
||||||
if((h != NULL) && (h != INVALID_HANDLE_VALUE))
|
if(VALID_HANDLE(h))
|
||||||
{
|
{
|
||||||
CloseHandle(h);
|
CloseHandle(h);
|
||||||
h = NULL;
|
h = NULL;
|
||||||
@ -145,13 +147,13 @@ LockedFile::LockedFile(QResource *const resource, const QString &outPath, const
|
|||||||
for(int i = 0; i < 64; i++)
|
for(int i = 0; i < 64; i++)
|
||||||
{
|
{
|
||||||
fileHandle = CreateFileW(MUTILS_WCHR(QDir::toNativeSeparators(m_filePath)), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, NULL, NULL);
|
fileHandle = CreateFileW(MUTILS_WCHR(QDir::toNativeSeparators(m_filePath)), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, NULL, NULL);
|
||||||
if((fileHandle != NULL) && (fileHandle != INVALID_HANDLE_VALUE)) break;
|
if(VALID_HANDLE(fileHandle)) break;
|
||||||
if(!i) qWarning("Failed to lock file on first attemp, retrying...");
|
if(!i) qWarning("Failed to lock file on first attemp, retrying...");
|
||||||
Sleep(100);
|
Sleep(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Locked successfully?
|
//Locked successfully?
|
||||||
if((fileHandle == NULL) || (fileHandle == INVALID_HANDLE_VALUE))
|
if(!VALID_HANDLE(fileHandle))
|
||||||
{
|
{
|
||||||
QFile::remove(QFileInfo(outFile).canonicalFilePath());
|
QFile::remove(QFileInfo(outFile).canonicalFilePath());
|
||||||
MUTILS_THROW_FMT("File '%s' could not be locked!", MUTILS_UTF8(QFileInfo(m_filePath).fileName()));
|
MUTILS_THROW_FMT("File '%s' could not be locked!", MUTILS_UTF8(QFileInfo(m_filePath).fileName()));
|
||||||
@ -224,13 +226,13 @@ LockedFile::LockedFile(const QString &filePath, const bool bOwnsFile)
|
|||||||
for(int i = 0; i < 64; i++)
|
for(int i = 0; i < 64; i++)
|
||||||
{
|
{
|
||||||
fileHandle = CreateFileW(MUTILS_WCHR(QDir::toNativeSeparators(m_filePath)), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, NULL, NULL);
|
fileHandle = CreateFileW(MUTILS_WCHR(QDir::toNativeSeparators(m_filePath)), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, NULL, NULL);
|
||||||
if((fileHandle != NULL) && (fileHandle != INVALID_HANDLE_VALUE)) break;
|
if(VALID_HANDLE(fileHandle)) break;
|
||||||
if(!i) qWarning("Failed to lock file on first attemp, retrying...");
|
if(!i) qWarning("Failed to lock file on first attemp, retrying...");
|
||||||
Sleep(100);
|
Sleep(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Locked successfully?
|
//Locked successfully?
|
||||||
if((fileHandle == NULL) || (fileHandle == INVALID_HANDLE_VALUE))
|
if(!VALID_HANDLE(fileHandle))
|
||||||
{
|
{
|
||||||
MUTILS_THROW_FMT("File '%s' could not be locked!", MUTILS_UTF8(QFileInfo(m_filePath).fileName()));
|
MUTILS_THROW_FMT("File '%s' could not be locked!", MUTILS_UTF8(QFileInfo(m_filePath).fileName()));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user