diff --git a/src/Config.h b/src/Config.h index 0951b484..f1cf4407 100644 --- a/src/Config.h +++ b/src/Config.h @@ -34,8 +34,8 @@ #define VER_LAMEXP_MINOR_HI 1 #define VER_LAMEXP_MINOR_LO 2 #define VER_LAMEXP_TYPE Beta -#define VER_LAMEXP_PATCH 6 -#define VER_LAMEXP_BUILD 1801 +#define VER_LAMEXP_PATCH 7 +#define VER_LAMEXP_BUILD 1803 #define VER_LAMEXP_CONFG 1700 /////////////////////////////////////////////////////////////////////////////// diff --git a/src/Global_Tools.cpp b/src/Global_Tools.cpp index 7a74dd39..a2caa9fc 100644 --- a/src/Global_Tools.cpp +++ b/src/Global_Tools.cpp @@ -74,6 +74,7 @@ static const quint32 g_max_uint32 = UINT32_MAX; static void lamexp_tools_clean_up(void) { QWriteLocker writeLock(&g_lamexp_tools_lock); + qWarning("------------ lamexp_tools_clean_up ------------"); if(!g_lamexp_tools_data.isNull()) { diff --git a/src/LockedFile.cpp b/src/LockedFile.cpp index 0c455028..14d33b3e 100644 --- a/src/LockedFile.cpp +++ b/src/LockedFile.cpp @@ -192,6 +192,19 @@ static __forceinline void doValidateHash(HANDLE &fileHandle, const int &fileDesc } } +static __forceinline bool doRemoveFile(const QString &filePath) +{ + for(int i = 0; i < 32; i++) + { + if(MUtils::remove_file(filePath)) + { + return true; + } + MUtils::OS::sleep_ms(1); + } + return false; +} + /////////////////////////////////////////////////////////////////////////////// LockedFile::LockedFile(QResource *const resource, const QString &outPath, const QByteArray &expectedHash, const bool bOwnsFile) @@ -263,6 +276,8 @@ LockedFile::LockedFile(const QString &filePath, const bool bOwnsFile) LockedFile::~LockedFile(void) { + qWarning("------------ LockedFile::~LockedFile ------------"); + if(m_fileDescriptor >= 0) { _close(m_fileDescriptor); @@ -270,14 +285,7 @@ LockedFile::~LockedFile(void) } if(m_bOwnsFile) { - if(QFileInfo(m_filePath).exists()) - { - for(int i = 0; i < 64; i++) - { - if(QFile::remove(m_filePath)) break; - MUtils::OS::sleep_ms(1); - } - } + doRemoveFile(m_filePath); } } diff --git a/src/Thread_Initialization.cpp b/src/Thread_Initialization.cpp index 39162446..1b64829a 100644 --- a/src/Thread_Initialization.cpp +++ b/src/Thread_Initialization.cpp @@ -181,6 +181,7 @@ public: ExtractorTask(QResource *const toolResource, const QDir &appDir, const QString &toolName, const QByteArray &toolHash, const unsigned int toolVersion, const QString &toolTag) : m_appDir(appDir), + m_tempPath(MUtils::temp_folder()), m_toolName(toolName), m_toolHash(toolHash), m_toolVersion(toolVersion), @@ -259,7 +260,7 @@ protected: if(lockedFile.isNull()) { qDebug("Extracting file: %s -> %s", m_toolName.toLatin1().constData(), toolShrtName.toLatin1().constData()); - lockedFile.reset(new LockedFile(m_toolResource.data(), QString("%1/lxp_%2").arg(MUtils::temp_folder(), toolShrtName), m_toolHash)); + lockedFile.reset(new LockedFile(m_toolResource.data(), QString("%1/lxp_%2").arg(m_tempPath, toolShrtName), m_toolHash)); } //Register tool @@ -267,14 +268,14 @@ protected: } private: + static volatile bool s_bCustom; QScopedPointer m_toolResource; - const QDir m_appDir; - const QString m_toolName; - const QByteArray m_toolHash; - const unsigned int m_toolVersion; - const QString m_toolTag; - - static volatile bool s_bCustom; + const QDir m_appDir; + const QString m_tempPath; + const QString m_toolName; + const QByteArray m_toolHash; + const unsigned int m_toolVersion; + const QString m_toolTag; }; volatile bool ExtractorTask::s_bCustom = false; diff --git a/src/Thread_Process.cpp b/src/Thread_Process.cpp index 4e0267fb..372375bd 100644 --- a/src/Thread_Process.cpp +++ b/src/Thread_Process.cpp @@ -525,30 +525,10 @@ QString ProcessThread::applyRegularExpression(const QString &fileName) QString ProcessThread::generateTempFileName(void) { - bool bOkay = false; - QString tempFileName; - - for(int i = 0; i < 4096; i++) + const QString tempFileName = MUtils::make_temp_file(m_tempDirectory, "wav", true); + if(tempFileName.isEmpty()) { - tempFileName = QString("%1/%2.wav").arg(m_tempDirectory, MUtils::rand_str()); - if(m_tempFiles.contains(tempFileName, Qt::CaseInsensitive) || QFileInfo(tempFileName).exists()) - { - continue; - } - - QFile file(tempFileName); - if(file.open(QFile::ReadWrite)) - { - file.close(); - bOkay = true; - break; - } - } - - if(!bOkay) - { - qWarning("Failed to generate unique temp file name!"); - return QString("%1/~whoops.wav").arg(m_tempDirectory); + return QString("%1/~whoops%2.wav").arg(m_tempDirectory, QString::number(MUtils::next_rand32())); } m_tempFiles << tempFileName;