+#endif //wxUSE_GUI
+
+// ----------------------------------------------------------------------------
+// wxEventLoopActivator: helper class for wxEventLoop implementations
+// ----------------------------------------------------------------------------
+
+// this object sets the wxEventLoop given to the ctor as the currently active
+// one and unsets it in its dtor, this is especially useful in presence of
+// exceptions but is more tidy even when we don't use them
+class wxEventLoopActivator
+{
+public:
+ wxEventLoopActivator(wxEventLoopBase *evtLoop)
+ {
+ m_evtLoopOld = wxEventLoopBase::GetActive();
+ wxEventLoopBase::SetActive(evtLoop);
+ }
+
+ ~wxEventLoopActivator()
+ {
+ // restore the previously active event loop
+ wxEventLoopBase::SetActive(m_evtLoopOld);
+ }
+
+private:
+ wxEventLoopBase *m_evtLoopOld;
+};
+
+#if wxUSE_CONSOLE_EVENTLOOP
+
+class wxEventLoopGuarantor
+{
+public:
+ wxEventLoopGuarantor()
+ {
+ m_evtLoopNew = NULL;
+ if (!wxEventLoop::GetActive())
+ {
+ m_evtLoopNew = new wxEventLoop;
+ wxEventLoop::SetActive(m_evtLoopNew);
+ }
+ }
+
+ ~wxEventLoopGuarantor()
+ {
+ if (m_evtLoopNew)
+ {
+ wxEventLoop::SetActive(NULL);
+ delete m_evtLoopNew;
+ }
+ }
+
+private:
+ wxEventLoop *m_evtLoopNew;
+};
+
+#endif // wxUSE_CONSOLE_EVENTLOOP
+