#include "wx/dynlib.h"
#include "wx/evtloop.h"
#include "wx/thread.h"
+#include "wx/scopeguard.h"
#include "wx/msw/private.h"
#include "wx/msw/dc.h"
typedef HRESULT (CALLBACK* DLLGETVERSIONPROC)(DLLVERSIONINFO *);
#endif // defined(DLLVERSIONINFO)
+#ifndef ATTACH_PARENT_PROCESS
+ #define ATTACH_PARENT_PROCESS ((DWORD)-1)
+#endif
// ---------------------------------------------------------------------------
// global variables
{
if ( m_ok == -1 )
{
- wxConsoleStderr * const self = wx_const_cast(wxConsoleStderr *, this);
+ wxConsoleStderr * const self = const_cast<wxConsoleStderr *>(this);
self->m_ok = self->DoInit();
// no need to call IsHistoryUnchanged() as we just initialized
// we're prepared to handle the errors
wxLogNull noLog;
- // the DLL should really be available
- wxDynamicLibrary dllComCtl32(_T("comctl32.dll"), wxDL_VERBATIM);
+ // we don't want to load comctl32.dll, it should be already loaded but,
+ // depending on the OS version and the presence of the manifest, it can
+ // be either v5 or v6 and instead of trying to guess it just get the
+ // handle of the already loaded version
+ wxDynamicLibrary dllComCtl32(_T("comctl32.dll"),
+ wxDL_VERBATIM |
+ wxDL_QUIET |
+ wxDL_GET_LOADED);
if ( !dllComCtl32.IsLoaded() )
{
s_verComCtl32 = 0;
}
}
}
+
+ // we shouldn't unload it here as we didn't really load it above
+ dllComCtl32.Detach();
}
return s_verComCtl32;
// MT-FIXME
static bool s_inYield = false;
-#if wxUSE_LOG
- // disable log flushing from here because a call to wxYield() shouldn't
- // normally result in message boxes popping up &c
- wxLog::Suspend();
-#endif // wxUSE_LOG
-
if ( s_inYield )
{
if ( !onlyIfNeeded )
return false;
}
+ // set the flag and don't forget to reset it before returning
s_inYield = true;
+ wxON_BLOCK_EXIT_SET(s_inYield, false);
+
+
+#if wxUSE_LOG
+ // disable log flushing from here because a call to wxYield() shouldn't
+ // normally result in message boxes popping up &c
+ wxLog::Suspend();
+
+ // ensure the logs will be flashed again when we exit
+ wxON_BLOCK_EXIT0(wxLog::Resume);
+#endif // wxUSE_LOG
+
// we don't want to process WM_QUIT from here - it should be processed in
// the main event loop in order to stop it
// if there are pending events, we must process them.
ProcessPendingEvents();
-#if wxUSE_LOG
- // let the logs be flashed again
- wxLog::Resume();
-#endif // wxUSE_LOG
-
- s_inYield = false;
-
return true;
}