Change current directory to root directory *before* trying to clean up the TEMP folder. This avoids the TEMP directory from being removed, because it is the current directory.
This commit is contained in:
parent
c3b213dcbc
commit
c3a7afa509
@ -157,6 +157,7 @@ static void temp_folder_cleanup_helper(const QString &tempPath)
|
|||||||
bool okay = false;
|
bool okay = false;
|
||||||
for(int i = 0; i < 32; i++)
|
for(int i = 0; i < 32; i++)
|
||||||
{
|
{
|
||||||
|
QDir::setCurrent(QDir::rootPath());
|
||||||
if(MUtils::remove_directory(tempPath, true))
|
if(MUtils::remove_directory(tempPath, true))
|
||||||
{
|
{
|
||||||
okay = true;
|
okay = true;
|
||||||
|
@ -180,6 +180,27 @@ int MUtils::Startup::startup(int &argc, char **argv, main_function_t *const entr
|
|||||||
static QMutex g_init_lock;
|
static QMutex g_init_lock;
|
||||||
static const char *const g_imageformats[] = {"bmp", "png", "jpg", "gif", "ico", "xpm", "svg", NULL};
|
static const char *const g_imageformats[] = {"bmp", "png", "jpg", "gif", "ico", "xpm", "svg", NULL};
|
||||||
|
|
||||||
|
static QString getExecutableName(int &argc, char **argv)
|
||||||
|
{
|
||||||
|
if(argc >= 1)
|
||||||
|
{
|
||||||
|
const char *argv0 = argv[0];
|
||||||
|
if(const char *const ptr = strrchr(argv0, '/'))
|
||||||
|
{
|
||||||
|
argv0 = ptr + 1;
|
||||||
|
}
|
||||||
|
if(const char *const ptr = strrchr(argv0, '\\'))
|
||||||
|
{
|
||||||
|
argv0 = ptr + 1;
|
||||||
|
}
|
||||||
|
if(strlen(argv0) > 1)
|
||||||
|
{
|
||||||
|
QString::fromLatin1(argv0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return QLatin1String("Program.exe");
|
||||||
|
}
|
||||||
|
|
||||||
QApplication *MUtils::Startup::create_qt(int &argc, char **argv, const QString &appName)
|
QApplication *MUtils::Startup::create_qt(int &argc, char **argv, const QString &appName)
|
||||||
{
|
{
|
||||||
QMutexLocker lock(&g_init_lock);
|
QMutexLocker lock(&g_init_lock);
|
||||||
@ -193,22 +214,7 @@ QApplication *MUtils::Startup::create_qt(int &argc, char **argv, const QString &
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Extract executable name from argv[] array
|
//Extract executable name from argv[] array
|
||||||
QString executableName = QLatin1String("LameXP.exe");
|
const QString executableName = getExecutableName(argc, argv);
|
||||||
if(arguments.count() > 0)
|
|
||||||
{
|
|
||||||
static const char *delimiters = "\\/:?";
|
|
||||||
executableName = arguments[0].trimmed();
|
|
||||||
for(int i = 0; delimiters[i]; i++)
|
|
||||||
{
|
|
||||||
int temp = executableName.lastIndexOf(QChar(delimiters[i]));
|
|
||||||
if(temp >= 0) executableName = executableName.mid(temp + 1);
|
|
||||||
}
|
|
||||||
executableName = executableName.trimmed();
|
|
||||||
if(executableName.isEmpty())
|
|
||||||
{
|
|
||||||
executableName = QLatin1String("LameXP.exe");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Check Qt version
|
//Check Qt version
|
||||||
#ifdef QT_BUILD_KEY
|
#ifdef QT_BUILD_KEY
|
||||||
|
Loading…
Reference in New Issue
Block a user