qtmain_win.cpp: Improve coding style
Change-Id: I08c722f4ff8a088d13af5b7d9cfbc88258d533ad Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
This commit is contained in:
parent
fd1ebef13e
commit
aea357c6bd
@ -82,7 +82,7 @@ extern "C" int main(int, char **);
|
||||
|
||||
// Convert a wchar_t to char string, equivalent to QString::toLocal8Bit()
|
||||
// when passed CP_ACP.
|
||||
static inline char *wideToMulti(int codePage, const wchar_t *aw)
|
||||
static inline char *wideToMulti(unsigned int codePage, const wchar_t *aw)
|
||||
{
|
||||
const int required = WideCharToMultiByte(codePage, 0, aw, -1, nullptr, 0, nullptr, nullptr);
|
||||
char *result = new char[required];
|
||||
@ -92,17 +92,17 @@ static inline char *wideToMulti(int codePage, const wchar_t *aw)
|
||||
|
||||
extern "C" int APIENTRY WinMain(HINSTANCE, HINSTANCE, LPSTR /*cmdParamarg*/, int /* cmdShow */)
|
||||
{
|
||||
int argc;
|
||||
int argc = 0;
|
||||
wchar_t **argvW = CommandLineToArgvW(GetCommandLineW(), &argc);
|
||||
if (!argvW)
|
||||
if (argvW == nullptr)
|
||||
return -1;
|
||||
char **argv = new char *[argc + 1];
|
||||
for (int i = 0; i < argc; ++i)
|
||||
for (int i = 0; i != argc; ++i)
|
||||
argv[i] = wideToMulti(CP_ACP, argvW[i]);
|
||||
argv[argc] = nullptr;
|
||||
LocalFree(argvW);
|
||||
const int exitCode = main(argc, argv);
|
||||
for (int i = 0; i < argc && argv[i]; ++i)
|
||||
for (int i = 0; (i != argc) && (argv[i] != nullptr); ++i)
|
||||
delete [] argv[i];
|
||||
delete [] argv;
|
||||
return exitCode;
|
||||
|
Loading…
Reference in New Issue
Block a user