From 9c26672d4dec695ef7d8955a4dbee43b854b8677 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 27 Dec 2008 00:04:57 +0000 Subject: [PATCH] move generic DispatchTimeout() implementation in the header as evtloopcmn.cpp is part of wxBase and so can't define a method of a wxCore class git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@57575 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/evtloop.h | 17 +++++++++++++++-- src/common/evtloopcmn.cpp | 20 -------------------- 2 files changed, 15 insertions(+), 22 deletions(-) diff --git a/include/wx/evtloop.h b/include/wx/evtloop.h index 5d78a3bf56..412fe4ea51 100644 --- a/include/wx/evtloop.h +++ b/include/wx/evtloop.h @@ -128,7 +128,7 @@ protected: #include "wx/dfb/evtloop.h" #else // other platform -#define wxNEEDS_GENERIC_DISPATCH_TIMEOUT +#include "wx/stopwatch.h" // for wxMilliClock_t class WXDLLIMPEXP_FWD_CORE wxEventLoopImpl; @@ -142,7 +142,20 @@ public: virtual void Exit(int rc = 0); virtual bool Pending() const; virtual bool Dispatch(); - virtual int DispatchTimeout(unsigned long timeout); + virtual int DispatchTimeout(unsigned long timeout) + { + // TODO: this is, of course, horribly inefficient and a proper wait with + // timeout should be implemented for all ports natively... + const wxMilliClock_t timeEnd = wxGetLocalTimeMillis() + timeout; + for ( ;; ) + { + if ( Pending() ) + return Dispatch(); + + if ( wxGetLocalTimeMillis() >= timeEnd ) + return -1; + } + } virtual void WakeUp() { } protected: diff --git a/src/common/evtloopcmn.cpp b/src/common/evtloopcmn.cpp index 808e82c972..18f9967c57 100644 --- a/src/common/evtloopcmn.cpp +++ b/src/common/evtloopcmn.cpp @@ -28,7 +28,6 @@ #ifndef WX_PRECOMP #include "wx/app.h" - #include "wx/stopwatch.h" // for wxMilliClock_t #endif //WX_PRECOMP // ---------------------------------------------------------------------------- @@ -155,22 +154,3 @@ void wxEventLoopManual::Exit(int rc) #endif // __WXMSW__ || __WXMAC__ || __WXDFB__ -#ifdef wxNEEDS_GENERIC_DISPATCH_TIMEOUT - -int wxGUIEventLoop::DispatchTimeout(unsigned long timeout) -{ - // TODO: this is, of course, horribly inefficient and a proper wait with - // timeout should be implemented for all ports natively... - const wxMilliClock_t timeEnd = wxGetLocalTimeMillis() + timeout; - for ( ;; ) - { - if ( Pending() ) - return Dispatch(); - - if ( wxGetLocalTimeMillis() >= timeEnd ) - return -1; - } -} - -#endif // wxNEEDS_GENERIC_DISPATCH_TIMEOUT - -- 2.45.2