#ifdef __GNUG__
#pragma implementation "app.h"
- #pragma implementation "appbase.h"
#endif
// For compilers that support precompilation, includes "wx.h".
#include "wx/msgdlg.h"
#include "wx/intl.h"
#include "wx/dynarray.h"
-# include "wx/wxchar.h"
-# include "wx/icon.h"
+ #include "wx/wxchar.h"
+ #include "wx/icon.h"
#endif
#include "wx/log.h"
extern wxChar *wxOsVersion;
extern wxList *wxWinHandleList;
extern wxList WXDLLEXPORT wxPendingDelete;
-#if wxUSE_THREADS
-extern wxList *wxPendingEvents;
-extern wxCriticalSection *wxPendingEventsLocker;
-#endif
extern void wxSetKeyboardHook(bool doIt);
extern wxCursor *g_globalCursor;
HBRUSH wxDisableButtonBrush = (HBRUSH) 0;
-LRESULT APIENTRY wxWndProc(HWND, UINT, WPARAM, LPARAM);
+LRESULT WXDLLEXPORT APIENTRY wxWndProc(HWND, UINT, WPARAM, LPARAM);
#if defined(__WIN95__) && !defined(__TWIN32__)
#define wxUSE_RICHEDIT 1
wxGetResource(wxT("wxWindows"), wxT("OsVersion"), &wxOsVersion);
#endif
- // I'm annoyed ... I don't know where to put this and I don't want to
- // create a module for that as it's part of the core.
#if wxUSE_THREADS
- wxPendingEvents = new wxList();
- wxPendingEventsLocker = new wxCriticalSection();
+ wxPendingEventsLocker = new wxCriticalSection;
#endif
wxTheColourDatabase = new wxColourDatabase(wxKEY_STRING);
if (wxWinHandleList)
delete wxWinHandleList;
- // GL: I'm annoyed ... I don't know where to put this and I don't want to
+ // GL: I'm annoyed ... I don't know where to put this and I don't want to
// create a module for that as it's part of the core.
-#if wxUSE_THREADS
delete wxPendingEvents;
+#if wxUSE_THREADS
delete wxPendingEventsLocker;
// If we don't do the following, we get an apparent memory leak.
((wxEvtHandler&) wxDefaultValidator).ClearEventLocker();
// but this call is provided for compatibility across platforms.
wxTheApp->OnInitGui();
+ // We really don't want timestamps by default, because it means
+ // we can't simply double-click on the error message and get to that
+ // line in the source. So VC++ at least, let's have a sensible default.
+#ifdef __VISUALC__
+ wxLog::SetTimestamp(NULL);
+#endif
+
int retValue = 0;
if ( wxTheApp->OnInit() )
return event.MoreRequested();
}
-#if wxUSE_THREADS
-void wxApp::ProcessPendingEvents()
-{
- wxNode *node = wxPendingEvents->First();
- wxCriticalSectionLocker locker(*wxPendingEventsLocker);
-
- while (node)
- {
- wxEvtHandler *handler = (wxEvtHandler *)node->Data();
-
- handler->ProcessPendingEvents();
-
- delete node;
- node = wxPendingEvents->First();
- }
-}
-#endif
-
-
void wxApp::ExitMainLoop()
{
m_keepGoing = FALSE;
while ( hWnd && !wndThis )
{
hWnd = ::GetParent(hWnd);
- wndThis = wxFindWinFromHandle((WXHWND)hWnd);
+ wndThis = wxFindWinFromHandle((WXHWND)hWnd);
}
// Try translations first; find the youngest window with
event.RequestMore(TRUE);
}
- // If they are pending events, we must process them.
-#if wxUSE_THREADS
+ // If they are pending events, we must process them: pending events are
+ // either events to the threads other than main or events posted with
+ // wxPostEvent() functions
ProcessPendingEvents();
-#endif
+
s_inOnIdle = FALSE;
}
// Yield to incoming messages
bool wxYield()
{
+ // we don't want to process WM_QUIT from here - it should be processed in
+ // the main event loop in order to stop it
+
MSG msg;
- // We want to go back to the main message loop
- // if we see a WM_QUIT. (?)
-#ifdef __WXWINE__
- while (PeekMessage(&msg, (HWND)NULL, 0, 0, PM_NOREMOVE) && msg.message != WM_QUIT)
-#else
- while (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE) && msg.message != WM_QUIT)
-#endif
+ while ( PeekMessage(&msg, (HWND)0, 0, 0, PM_NOREMOVE) &&
+ msg.message != WM_QUIT )
{
if ( !wxTheApp->DoMessage() )
break;
}
+
// If they are pending events, we must process them.
-#if wxUSE_THREADS
wxTheApp->ProcessPendingEvents();
-#endif
return TRUE;
}