Skip to content

Commit

Permalink
winmain.cpp: add console switch for leak detection
Browse files Browse the repository at this point in the history
- Add the '-leakdetect' switch to allow for console debugger memory
  leak detection and app exit for build testing.

[#33]

Signed-off-by: Thell Fowler <git@tbfowler.name>
  • Loading branch information
Thell Fowler committed Feb 14, 2010
1 parent 81d2d97 commit b9ac49b
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions PowerEditor/src/winmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ int getNumberFromParam(char paramName, ParamVector & params, bool & isParamePres
#define FLAG_RUN_UNITTESTS TEXT("-unittests") // "Secret" option
#endif

#ifdef _DEBUG
#define FLAG_LEAK_DETECT TEXT("-leakdetect") // "Secret" option
#endif

#define COMMAND_ARG_HELP TEXT("Usage :\n\
\n\
notepad++ [--help] [-multiInst] [-noPlugins] [-lLanguage] [-nLineNumber] [-cColumnNumber] [-xPos] [-yPos] [-nosession] [-notabbar] [-ro] [-systemtray] [fullFilePathName]\n\
Expand Down Expand Up @@ -217,6 +221,10 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR /*cmdLineAnsi*/, int /*
bool showHelp = isInList(FLAG_HELP, params);
bool isMultiInst = isInList(FLAG_MULTI_INSTANCE, params);

#ifdef _DEBUG
bool isLeakDetect = isInList(FLAG_LEAK_DETECT, params);
#endif

CmdLineParams cmdLineParams;
cmdLineParams._isNoTab = isInList(FLAG_NOTABBAR, params);
cmdLineParams._isNoPlugin = isInList(FLAG_NO_PLUGIN, params);
Expand Down Expand Up @@ -368,6 +376,14 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR /*cmdLineAnsi*/, int /*
try {
notepad_plus_plus.init(hInstance, NULL, quotFileName.c_str(), &cmdLineParams);
bool unicodeSupported = getWinVersion() >= WV_NT;
#ifdef _DEBUG
// mem leak check output for build-testing.
if (isLeakDetect)
{
::SendMessage(notepad_plus_plus.gNppHWND, WM_CLOSE, 0, 0);
return 0;
};
#endif
bool going = true;
while (going)
{
Expand Down

0 comments on commit b9ac49b

Please sign in to comment.