X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/6f2df739f416d5f00bd294c7a29f71a46cd61fc2..b1c6a00e631be013b9dc3eb43959c80369a99e56:/src/msw/main.cpp diff --git a/src/msw/main.cpp b/src/msw/main.cpp index ead91896d5..712dc72347 100644 --- a/src/msw/main.cpp +++ b/src/msw/main.cpp @@ -17,10 +17,6 @@ // headers // ---------------------------------------------------------------------------- -#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) - #pragma implementation -#endif - // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" @@ -31,6 +27,7 @@ #include "wx/event.h" #include "wx/app.h" #include "wx/cmdline.h" +#include "wx/scopeguard.h" #include "wx/msw/private.h" @@ -282,8 +279,7 @@ static bool wxIsUnicodeAvailable() ); return false; -#endif // !wxUSE_UNICODE_MSLU - +#else // wxUSE_UNICODE_MSLU // and the MSLU DLL must also be available HMODULE hmod = ::LoadLibraryA("unicows.dll"); if ( !hmod ) @@ -324,6 +320,7 @@ static bool wxIsUnicodeAvailable() } ::FreeLibrary(hmod); +#endif // !wxUSE_UNICODE_MSLU } return true; @@ -335,6 +332,20 @@ static bool wxIsUnicodeAvailable() // Windows-specific wxEntry // ---------------------------------------------------------------------------- +// helper function used to clean up in wxEntry() just below +// +// notice that argv elements are supposed to be allocated using malloc() while +// argv array itself is allocated with new +static void wxFreeArgs(int argc, wxChar **argv) +{ + for ( int i = 0; i < argc; i++ ) + { + free(argv[i]); + } + + delete [] argv; +} + WXDLLEXPORT int wxEntry(HINSTANCE hInstance, HINSTANCE WXUNUSED(hPrevInstance), wxCmdLineArgType WXUNUSED(pCmdLine), @@ -383,58 +394,11 @@ WXDLLEXPORT int wxEntry(HINSTANCE hInstance, // argv[] must be NULL-terminated argv[argc] = NULL; - return wxEntry(argc, argv); -} - -// May wish not to have a DllMain or WinMain, e.g. if we're programming -// a Netscape plugin or if we're writing a console application -#if !defined(NOMAIN) - -extern "C" -{ - -// ---------------------------------------------------------------------------- -// WinMain -// ---------------------------------------------------------------------------- - -// Note that WinMain is also defined in dummy.obj, which is linked to -// an application that is using the DLL version of wxWidgets. - -#if defined(_WINDLL) + wxON_BLOCK_EXIT2(wxFreeArgs, argc, argv); -// DLL entry point - -BOOL WINAPI -DllMain(HINSTANCE hModule, DWORD fdwReason, LPVOID WXUNUSED(lpReserved)) -{ - // Only call wxEntry if the application itself is part of the DLL. - // If only the wxWidgets library is in the DLL, then the - // initialisation will be called when the application implicitly - // calls WinMain. -#ifndef WXMAKINGDLL - switch (fdwReason) - { - case DLL_PROCESS_ATTACH: - return wxEntry(hModule); - - case DLL_PROCESS_DETACH: - wxEntryCleanup(); - break; - } -#else - (void)hModule; - (void)fdwReason; -#endif // !WXMAKINGDLL - - return TRUE; + return wxEntry(argc, argv); } -#endif // _WINDLL - -} // extern "C" - -#endif // !NOMAIN - #endif // wxUSE_GUI && __WXMSW__ // ----------------------------------------------------------------------------