Extinguished some remaining uses of argv[] or QApplication::arguments().
This commit is contained in:
parent
30bc239cd8
commit
17794881a4
@ -125,6 +125,7 @@
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
<EntryPointSymbol>lamexp_entry_point</EntryPointSymbol>
|
||||
</Link>
|
||||
<PostBuildEvent>
|
||||
<Message>Copy plugin DLL%27s</Message>
|
||||
@ -168,6 +169,7 @@ copy /Y "$(SolutionDir)\etc\Prerequisites\VisualLeakDetector\bin\Win32\*.manifes
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
<EntryPointSymbol>lamexp_entry_point</EntryPointSymbol>
|
||||
</Link>
|
||||
<PostBuildEvent>
|
||||
<Message>Copy plugin DLL%27s</Message>
|
||||
@ -236,7 +238,7 @@ copy /Y "$(SolutionDir)\etc\Prerequisites\VisualLeakDetector\bin\Win32\*.manifes
|
||||
<SetChecksum>true</SetChecksum>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
<MinimumRequiredVersion>5.0</MinimumRequiredVersion>
|
||||
<EntryPointSymbol>lamexp_crt_startup</EntryPointSymbol>
|
||||
<EntryPointSymbol>lamexp_entry_point</EntryPointSymbol>
|
||||
<MapFileName>
|
||||
</MapFileName>
|
||||
<TreatLinkerWarningAsErrors>true</TreatLinkerWarningAsErrors>
|
||||
@ -306,7 +308,7 @@ del "$(TargetDir)imageformats\q???d4.dll"
|
||||
<SetChecksum>true</SetChecksum>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
<MinimumRequiredVersion>5.0</MinimumRequiredVersion>
|
||||
<EntryPointSymbol>lamexp_crt_startup</EntryPointSymbol>
|
||||
<EntryPointSymbol>lamexp_entry_point</EntryPointSymbol>
|
||||
<GenerateMapFile>false</GenerateMapFile>
|
||||
<MapFileName>
|
||||
</MapFileName>
|
||||
@ -371,7 +373,7 @@ del "$(TargetDir)imageformats\q???d4.dll"
|
||||
<SetChecksum>true</SetChecksum>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
<MinimumRequiredVersion>5.0</MinimumRequiredVersion>
|
||||
<EntryPointSymbol>lamexp_crt_startup</EntryPointSymbol>
|
||||
<EntryPointSymbol>lamexp_entry_point</EntryPointSymbol>
|
||||
<GenerateMapFile>false</GenerateMapFile>
|
||||
<MapFileName>
|
||||
</MapFileName>
|
||||
|
@ -3021,17 +3021,17 @@
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/Global.cpp" line="1059"/>
|
||||
<location filename="../../src/Global.cpp" line="1071"/>
|
||||
<source>Executable '%1' requires Qt v%2, but found Qt v%3.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/Global.cpp" line="1064"/>
|
||||
<location filename="../../src/Global.cpp" line="1076"/>
|
||||
<source>Executable '%1' was built for Qt '%2', but found Qt '%3'.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/Global.cpp" line="1077"/>
|
||||
<location filename="../../src/Global.cpp" line="1089"/>
|
||||
<source>Executable '%1' requires Windows 2000 or later.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
|
@ -3021,17 +3021,17 @@
|
||||
<translation type="unfinished">Plik wykonywalny '%1' nie działa w trybie kompatybilności z Windows.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/Global.cpp" line="1059"/>
|
||||
<location filename="../../src/Global.cpp" line="1071"/>
|
||||
<source>Executable '%1' requires Qt v%2, but found Qt v%3.</source>
|
||||
<translation type="unfinished">Plik wykonywalny '%1' wymaga Qt v%2, znaleziono jednak Qt v%3.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/Global.cpp" line="1064"/>
|
||||
<location filename="../../src/Global.cpp" line="1076"/>
|
||||
<source>Executable '%1' was built for Qt '%2', but found Qt '%3'.</source>
|
||||
<translation type="unfinished">Plik wykonywalny "%1" został skompilowany dla Qt "%2", znaleziono "%3".</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/Global.cpp" line="1077"/>
|
||||
<location filename="../../src/Global.cpp" line="1089"/>
|
||||
<source>Executable '%1' requires Windows 2000 or later.</source>
|
||||
<translation type="unfinished">Plik wykonywalny '%1' wymaga do uruchomienia Windows 2000 lub nowszego.</translation>
|
||||
</message>
|
||||
|
@ -3021,17 +3021,17 @@
|
||||
<translation>EXE-filen '%1' stöder inte Windows kompatibilitetsläge.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/Global.cpp" line="1059"/>
|
||||
<location filename="../../src/Global.cpp" line="1071"/>
|
||||
<source>Executable '%1' requires Qt v%2, but found Qt v%3.</source>
|
||||
<translation>EXE-filen '%1' kräver Qt v%2, du har Qt v%3.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/Global.cpp" line="1064"/>
|
||||
<location filename="../../src/Global.cpp" line="1076"/>
|
||||
<source>Executable '%1' was built for Qt '%2', but found Qt '%3'.</source>
|
||||
<translation>EXE-filen '%1' är byggd för Qt '%2', du har Qt '%3'.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/Global.cpp" line="1077"/>
|
||||
<location filename="../../src/Global.cpp" line="1089"/>
|
||||
<source>Executable '%1' requires Windows 2000 or later.</source>
|
||||
<translation>EXE-filen '%1' kräver Windows 2000 eller senare.</translation>
|
||||
</message>
|
||||
|
@ -30,7 +30,7 @@
|
||||
#define VER_LAMEXP_MINOR_LO 5
|
||||
#define VER_LAMEXP_TYPE Alpha
|
||||
#define VER_LAMEXP_PATCH 5
|
||||
#define VER_LAMEXP_BUILD 1040
|
||||
#define VER_LAMEXP_BUILD 1042
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Tool versions (minimum expected versions!)
|
||||
|
@ -407,7 +407,7 @@ void ProcessingDialog::initEncoding(void)
|
||||
unsigned int maximumInstances = qBound(0U, m_settings->maximumInstances(), MAX_INSTANCES);
|
||||
if(maximumInstances < 1)
|
||||
{
|
||||
lamexp_cpu_t cpuFeatures = lamexp_detect_cpu_features();
|
||||
lamexp_cpu_t cpuFeatures = lamexp_detect_cpu_features(lamexp_arguments());
|
||||
maximumInstances = cores2instances(qBound(1, cpuFeatures.count, 64));
|
||||
}
|
||||
|
||||
|
@ -625,7 +625,7 @@ void lamexp_init_console(const QStringList &argv)
|
||||
/*
|
||||
* Detect CPU features
|
||||
*/
|
||||
lamexp_cpu_t lamexp_detect_cpu_features(int argc, char **argv)
|
||||
lamexp_cpu_t lamexp_detect_cpu_features(const QStringList &argv)
|
||||
{
|
||||
typedef BOOL (WINAPI *IsWow64ProcessFun)(__in HANDLE hProcess, __out PBOOL Wow64Process);
|
||||
typedef VOID (WINAPI *GetNativeSystemInfoFun)(__out LPSYSTEM_INFO lpSystemInfo);
|
||||
@ -720,14 +720,14 @@ lamexp_cpu_t lamexp_detect_cpu_features(int argc, char **argv)
|
||||
features.x64 = true;
|
||||
#endif
|
||||
|
||||
if((argv != NULL) && (argc > 0))
|
||||
if(argv.count() > 0)
|
||||
{
|
||||
bool flag = false;
|
||||
for(int i = 0; i < argc; i++)
|
||||
for(int i = 0; i < argv.count(); i++)
|
||||
{
|
||||
if(!_stricmp("--force-cpu-no-64bit", argv[i])) { flag = true; features.x64 = false; }
|
||||
if(!_stricmp("--force-cpu-no-sse", argv[i])) { flag = true; features.sse = features.sse2 = features.sse3 = features.ssse3 = false; }
|
||||
if(!_stricmp("--force-cpu-no-intel", argv[i])) { flag = true; features.intel = false; }
|
||||
if(!argv[i].compare("--force-cpu-no-64bit", Qt::CaseInsensitive)) { flag = true; features.x64 = false; }
|
||||
if(!argv[i].compare("--force-cpu-no-sse", Qt::CaseInsensitive)) { flag = true; features.sse = features.sse2 = features.sse3 = features.ssse3 = false; }
|
||||
if(!argv[i].compare("--force-cpu-no-intel", Qt::CaseInsensitive)) { flag = true; features.intel = false; }
|
||||
}
|
||||
if(flag) qWarning("CPU flags overwritten by user-defined parameters. Take care!\n");
|
||||
}
|
||||
@ -804,7 +804,7 @@ static HANDLE lamexp_debug_thread_init(void)
|
||||
/*
|
||||
* Check for compatibility mode
|
||||
*/
|
||||
static bool lamexp_check_compatibility_mode(const char *exportName, const char *executableName)
|
||||
static bool lamexp_check_compatibility_mode(const char *exportName, const QString &executableName)
|
||||
{
|
||||
QLibrary kernel32("kernel32.dll");
|
||||
|
||||
@ -813,7 +813,7 @@ static bool lamexp_check_compatibility_mode(const char *exportName, const char *
|
||||
if(kernel32.resolve(exportName) != NULL)
|
||||
{
|
||||
qWarning("Function '%s' exported from 'kernel32.dll' -> Windows compatibility mode!", exportName);
|
||||
qFatal("%s", QApplication::tr("Executable '%1' doesn't support Windows compatibility mode.").arg(QString::fromLatin1(executableName)).toLatin1().constData());
|
||||
qFatal("%s", QApplication::tr("Executable '%1' doesn't support Windows compatibility mode.").arg(executableName).toLatin1().constData());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -1027,6 +1027,7 @@ bool lamexp_init_qt(int argc, char* argv[])
|
||||
{
|
||||
static bool qt_initialized = false;
|
||||
typedef BOOL (WINAPI *SetDllDirectoryProc)(WCHAR *lpPathName);
|
||||
const QStringList &arguments = lamexp_arguments();
|
||||
|
||||
//Don't initialized again, if done already
|
||||
if(qt_initialized)
|
||||
@ -1044,10 +1045,21 @@ bool lamexp_init_qt(int argc, char* argv[])
|
||||
}
|
||||
|
||||
//Extract executable name from argv[] array
|
||||
char *executableName = argv[0];
|
||||
while(char *temp = strpbrk(executableName, "\\/:?"))
|
||||
QString executableName = QLatin1String("LameXP.exe");
|
||||
if(arguments.count() > 0)
|
||||
{
|
||||
executableName = temp + 1;
|
||||
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
|
||||
@ -1056,12 +1068,12 @@ bool lamexp_init_qt(int argc, char* argv[])
|
||||
qDebug("Compiled with Qt v%s [%s], %s\n", QT_VERSION_STR, QT_PACKAGEDATE_STR, QT_BUILD_KEY);
|
||||
if(_stricmp(qVersion(), QT_VERSION_STR))
|
||||
{
|
||||
qFatal("%s", QApplication::tr("Executable '%1' requires Qt v%2, but found Qt v%3.").arg(QString::fromLatin1(executableName), QString::fromLatin1(QT_VERSION_STR), QString::fromLatin1(qVersion())).toLatin1().constData());
|
||||
qFatal("%s", QApplication::tr("Executable '%1' requires Qt v%2, but found Qt v%3.").arg(executableName, QString::fromLatin1(QT_VERSION_STR), QString::fromLatin1(qVersion())).toLatin1().constData());
|
||||
return false;
|
||||
}
|
||||
if(QLibraryInfo::buildKey().compare(QString::fromLatin1(QT_BUILD_KEY), Qt::CaseInsensitive))
|
||||
{
|
||||
qFatal("%s", QApplication::tr("Executable '%1' was built for Qt '%2', but found Qt '%3'.").arg(QString::fromLatin1(executableName), QString::fromLatin1(QT_BUILD_KEY), QLibraryInfo::buildKey()).toLatin1().constData());
|
||||
qFatal("%s", QApplication::tr("Executable '%1' was built for Qt '%2', but found Qt '%3'.").arg(executableName, QString::fromLatin1(QT_BUILD_KEY), QLibraryInfo::buildKey()).toLatin1().constData());
|
||||
return false;
|
||||
}
|
||||
#else
|
||||
@ -1074,7 +1086,7 @@ bool lamexp_init_qt(int argc, char* argv[])
|
||||
{
|
||||
case 0:
|
||||
case QSysInfo::WV_NT:
|
||||
qFatal("%s", QApplication::tr("Executable '%1' requires Windows 2000 or later.").arg(QString::fromLatin1(executableName)).toLatin1().constData());
|
||||
qFatal("%s", QApplication::tr("Executable '%1' requires Windows 2000 or later.").arg(executableName).toLatin1().constData());
|
||||
break;
|
||||
case QSysInfo::WV_2000:
|
||||
qDebug("Running on Windows 2000 (not officially supported!).\n");
|
||||
@ -2056,6 +2068,24 @@ QStringList lamexp_available_codepages(bool noAliases)
|
||||
return codecList;
|
||||
}
|
||||
|
||||
/*
|
||||
* Application entry point (runs before static initializers)
|
||||
*/
|
||||
extern "C"
|
||||
{
|
||||
int WinMainCRTStartup(void);
|
||||
|
||||
int lamexp_entry_point(void)
|
||||
{
|
||||
if((!LAMEXP_DEBUG) && lamexp_check_for_debugger())
|
||||
{
|
||||
FatalAppExit(0, L"Not a debug build. Please unload debugger and try again!");
|
||||
TerminateProcess(GetCurrentProcess(), -1);
|
||||
}
|
||||
return WinMainCRTStartup();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Finalization function (final clean-up)
|
||||
*/
|
||||
|
@ -119,7 +119,7 @@ QString lamexp_rand_str(void);
|
||||
const QString &lamexp_temp_folder2(void);
|
||||
void lamexp_ipc_read(unsigned int *command, char* message, size_t buffSize);
|
||||
void lamexp_ipc_send(unsigned int command, const char* message);
|
||||
lamexp_cpu_t lamexp_detect_cpu_features(int argc = 0, char **argv = NULL);
|
||||
lamexp_cpu_t lamexp_detect_cpu_features(const QStringList &argv);
|
||||
bool lamexp_portable_mode(void);
|
||||
bool lamexp_shutdown_computer(const QString &message, const unsigned long timeout = 30, const bool forceShutdown = true, const bool hibernate = false);
|
||||
bool lamexp_is_hibernation_supported(void);
|
||||
|
18
src/Main.cpp
18
src/Main.cpp
@ -83,7 +83,7 @@ static int lamexp_main(int argc, char* argv[])
|
||||
qDebug("");
|
||||
|
||||
//Detect CPU capabilities
|
||||
lamexp_cpu_t cpuFeatures = lamexp_detect_cpu_features(argc, argv);
|
||||
lamexp_cpu_t cpuFeatures = lamexp_detect_cpu_features(arguments);
|
||||
qDebug(" CPU vendor id : %s (Intel: %s)", cpuFeatures.vendor, LAMEXP_BOOL(cpuFeatures.intel));
|
||||
qDebug("CPU brand string : %s", cpuFeatures.brand);
|
||||
qDebug(" CPU signature : Family: %d, Model: %d, Stepping: %d", cpuFeatures.family, cpuFeatures.model, cpuFeatures.stepping);
|
||||
@ -131,7 +131,7 @@ static int lamexp_main(int argc, char* argv[])
|
||||
//Kill application?
|
||||
for(int i = 0; i < argc; i++)
|
||||
{
|
||||
if(!_stricmp("--kill", argv[i]) || !_stricmp("--force-kill", argv[i]))
|
||||
if(!arguments[i].compare("--kill", Qt::CaseInsensitive) || !arguments[i].compare("--force-kill", Qt::CaseInsensitive))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@ -283,17 +283,3 @@ int main(int argc, char* argv[])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// CRT initialization
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
extern "C"
|
||||
{
|
||||
int WinMainCRTStartup(void);
|
||||
|
||||
int lamexp_crt_startup(void)
|
||||
{
|
||||
return WinMainCRTStartup();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user