Skip to content

Commit

Permalink
qtmain_win.cpp: Improve coding style
Browse files Browse the repository at this point in the history
Change-Id: I08c722f4ff8a088d13af5b7d9cfbc88258d533ad
Reviewed-by: Friedemann Kleint <[email protected]>
  • Loading branch information
wangwenx190 committed Feb 3, 2019
1 parent fd1ebef commit aea357c
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/winmain/qtmain_win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -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;
Expand Down

0 comments on commit aea357c

Please sign in to comment.