More carefully check TEMP directory + fix fatal application exit.

This commit is contained in:
LoRd_MuldeR 2010-11-20 03:11:12 +01:00
parent 1633489aaf
commit 2ea5e07d6e
3 changed files with 36 additions and 14 deletions

View File

@ -16,9 +16,7 @@ if not "%ERRORLEVEL%"=="0" GOTO:EOF
echo ----------------------------------------------------------------
set "LAMEXP_ERROR=1"
msbuild.exe /property:Configuration=%2 /property:Platform=Win32 /target:Rebuild /verbosity:detailed %1
if not "%ERRORLEVEL%"=="0" (
msbuild.exe /property:Configuration=%2 /property:Platform=Win32 /target:Build /verbosity:detailed %1
if not "%ERRORLEVEL%"=="0" GOTO:EOF
)
msbuild.exe /property:Configuration=%2 /property:Platform=Win32 /target:Build /verbosity:detailed %1
if not "%ERRORLEVEL%"=="0" GOTO:EOF
echo ----------------------------------------------------------------
set "LAMEXP_ERROR=0"

View File

@ -25,7 +25,7 @@
#define VER_LAMEXP_MAJOR 4
#define VER_LAMEXP_MINOR_HI 0
#define VER_LAMEXP_MINOR_LO 0
#define VER_LAMEXP_BUILD 49
#define VER_LAMEXP_BUILD 50
#define VER_LAMEXP_SUFFIX TechPreview
/*

View File

@ -201,7 +201,7 @@ void lamexp_message_handler(QtMsgType type, const char *msg)
fflush(stderr);
SetConsoleTextAttribute(hConsole, FOREGROUND_RED | FOREGROUND_INTENSITY);
fprintf(stderr, "\nCRITICAL ERROR !!!\n%s\n\n", msg);
MessageBoxA(NULL, msg, "LameXP - CRITICAL ERROR", MB_ICONERROR | MB_TOPMOST | MB_TASKMODAL);
MessageBoxW(NULL, (wchar_t*) QString::fromUtf8(msg).utf16(), L"LameXP - CRITICAL ERROR", MB_ICONERROR | MB_TOPMOST | MB_TASKMODAL);
break;
case QtWarningMsg:
SetConsoleTextAttribute(hConsole, FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY);
@ -219,6 +219,7 @@ void lamexp_message_handler(QtMsgType type, const char *msg)
if(type == QtCriticalMsg || type == QtFatalMsg)
{
lock.unlock();
FatalAppExit(0, L"The application has encountered a critical error and will exit now!");
TerminateProcess(GetCurrentProcess(), -1);
}
@ -538,18 +539,41 @@ const QString &lamexp_temp_folder(void)
{
if(g_lamexp_temp_folder.isEmpty())
{
QDir tempFolder(QDir::tempPath());
QDir temp = QDir::temp();
if(!temp.exists())
{
temp.mkpath(".");
if(!temp.exists())
{
qFatal("The system's temporary directory does not exist:\n%s", temp.canonicalPath().toUtf8().constData());
return g_lamexp_temp_folder;
}
}
QString uuid = QUuid::createUuid().toString();
tempFolder.mkdir(uuid);
if(!temp.mkdir(uuid))
{
qFatal("Temporary directory could not be created:\n%s", QString("%1/%2").arg(temp.canonicalPath(), uuid).toUtf8().constData());
return g_lamexp_temp_folder;
}
if(!temp.cd(uuid))
{
qFatal("Temporary directory could not be entered:\n%s", QString("%1/%2").arg(temp.canonicalPath(), uuid).toUtf8().constData());
return g_lamexp_temp_folder;
}
if(tempFolder.cd(uuid))
QFile testFile(QString("%1/~test.txt").arg(temp.canonicalPath()));
if(!testFile.open(QIODevice::ReadWrite) || testFile.write("LAMEXP_TEST\n") < 12)
{
g_lamexp_temp_folder = tempFolder.canonicalPath();
}
else
{
g_lamexp_temp_folder = QDir::tempPath();
qFatal("Write access to temporary directory has been denied:\n%s", temp.canonicalPath().toUtf8().constData());
return g_lamexp_temp_folder;
}
testFile.close();
QFile::remove(testFile.fileName());
g_lamexp_temp_folder = temp.canonicalPath();
}
return g_lamexp_temp_folder;