Make wxEventLoop::AddSourceForFD() static.
Any event sources should be registered with all the event loops, including the ones that will be started in the future, and not only the current (and potentially not even existing yet) one. So make AddSourceForFD() method static. To still allow it to do different things in console and GUI applications, as it must, virtualize it via the new wxEventLoopSourcesManager class which has different implementations in the two cases, returned via wxAppTraits as usual. Notice that this required moving the implementation of this method from src/osx/core/evtloop_cf.cpp to src/osx/core/utilsexc_cf.cpp as the former file is base-only and didn't have access to wxGUIAppTraits. See #10258. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74341 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -79,9 +79,9 @@ public:
|
||||
|
||||
#if wxUSE_EVENTLOOP_SOURCE
|
||||
// create a new event loop source wrapping the given file descriptor and
|
||||
// start monitoring it
|
||||
virtual wxEventLoopSource *
|
||||
AddSourceForFD(int fd, wxEventLoopSourceHandler *handler, int flags) = 0;
|
||||
// monitor it for events occurring on this descriptor in all event loops
|
||||
static wxEventLoopSource *
|
||||
AddSourceForFD(int fd, wxEventLoopSourceHandler *handler, int flags);
|
||||
#endif // wxUSE_EVENTLOOP_SOURCE
|
||||
|
||||
// dispatch&processing
|
||||
@@ -296,19 +296,6 @@ public:
|
||||
wxGUIEventLoop() { m_impl = NULL; }
|
||||
virtual ~wxGUIEventLoop();
|
||||
|
||||
#if wxUSE_EVENTLOOP_SOURCE
|
||||
// We need to define a base class pure virtual method but we can't provide
|
||||
// a generic implementation for it so simply fail.
|
||||
virtual wxEventLoopSource *
|
||||
AddSourceForFD(int WXUNUSED(fd),
|
||||
wxEventLoopSourceHandler * WXUNUSED(handler),
|
||||
int WXUNUSED(flags))
|
||||
{
|
||||
wxFAIL_MSG( "support for event loop sources not implemented" );
|
||||
return NULL;
|
||||
}
|
||||
#endif // wxUSE_EVENTLOOP_SOURCE
|
||||
|
||||
virtual void ScheduleExit(int rc = 0);
|
||||
virtual bool Pending() const;
|
||||
virtual bool Dispatch();
|
||||
|
@@ -29,11 +29,6 @@ public:
|
||||
virtual void WakeUp();
|
||||
virtual bool YieldFor(long eventsToProcess);
|
||||
|
||||
#if wxUSE_EVENTLOOP_SOURCE
|
||||
virtual wxEventLoopSource *
|
||||
AddSourceForFD(int fd, wxEventLoopSourceHandler *handler, int flags);
|
||||
#endif // wxUSE_EVENTLOOP_SOURCE
|
||||
|
||||
void StoreGdkEventForLaterProcessing(GdkEvent* ev)
|
||||
{ m_arrGdkEvents.Add(ev); }
|
||||
|
||||
|
@@ -45,11 +45,6 @@ public:
|
||||
|
||||
virtual bool YieldFor(long eventsToProcess);
|
||||
|
||||
#if wxUSE_EVENTLOOP_SOURCE
|
||||
virtual wxEventLoopSource *
|
||||
AddSourceForFD(int fd, wxEventLoopSourceHandler *handler, int flags);
|
||||
#endif // wxUSE_EVENTLOOP_SOURCE
|
||||
|
||||
bool ShouldProcessIdleEvents() const { return m_processIdleEvents ; }
|
||||
|
||||
#if wxUSE_UIACTIONSIMULATOR
|
||||
|
@@ -17,7 +17,7 @@ typedef struct __CFFileDescriptor *CFFileDescriptorRef;
|
||||
// wxCFEventLoopSource: CoreFoundation-based wxEventLoopSource for OS X
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class wxCFEventLoopSource : public wxEventLoopSource
|
||||
class WXDLLIMPEXP_BASE wxCFEventLoopSource : public wxEventLoopSource
|
||||
{
|
||||
public:
|
||||
wxCFEventLoopSource(wxEventLoopSourceHandler *handler, int flags)
|
||||
|
26
include/wx/private/eventloopsourcesmanager.h
Normal file
26
include/wx/private/eventloopsourcesmanager.h
Normal file
@@ -0,0 +1,26 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/private/eventloopsourcesmanager.h
|
||||
// Purpose: declares wxEventLoopSourcesManagerBase class
|
||||
// Author: Rob Bresalier
|
||||
// Created: 2013-06-19
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 2013 Rob Bresalier
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_PRIVATE_EVENTLOOPSOURCESMANAGER_H_
|
||||
#define _WX_PRIVATE_EVENTLOOPSOURCESMANAGER_H_
|
||||
|
||||
// For pulling in the value of wxUSE_EVENTLOOP_SOURCE
|
||||
#include "wx/evtloop.h"
|
||||
|
||||
class WXDLLIMPEXP_BASE wxEventLoopSourcesManagerBase
|
||||
{
|
||||
public:
|
||||
#if wxUSE_EVENTLOOP_SOURCE
|
||||
virtual wxEventLoopSource*
|
||||
AddSourceForFD(int fd, wxEventLoopSourceHandler *handler, int flags) = 0;
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif // _WX_PRIVATE_EVENTLOOPSOURCESMANAGER_H_
|
@@ -15,6 +15,7 @@
|
||||
struct wxEndProcessData;
|
||||
struct wxExecuteData;
|
||||
class wxFDIOManager;
|
||||
class wxEventLoopSourcesManagerBase;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxAppTraits: the Unix version adds extra hooks needed by Unix code
|
||||
@@ -56,6 +57,10 @@ public:
|
||||
virtual wxFDIOManager *GetFDIOManager();
|
||||
#endif // wxUSE_SOCKETS
|
||||
|
||||
// Return a non-NULL pointer to the object responsible for managing the
|
||||
// event loop sources in this kind of application.
|
||||
virtual wxEventLoopSourcesManagerBase* GetEventLoopSourcesManager();
|
||||
|
||||
protected:
|
||||
// a helper for the implementation of WaitForChild() in wxGUIAppTraits:
|
||||
// checks the streams used for redirected IO in execData and returns true
|
||||
|
@@ -88,6 +88,8 @@ public:
|
||||
#endif
|
||||
|
||||
#endif // wxUSE_SOCKETS
|
||||
|
||||
virtual wxEventLoopSourcesManagerBase* GetEventLoopSourcesManager();
|
||||
};
|
||||
|
||||
#endif // wxUSE_GUI
|
||||
|
@@ -41,11 +41,6 @@ public:
|
||||
virtual bool IsOk() const { return m_dispatcher != NULL; }
|
||||
virtual bool YieldFor(long WXUNUSED(eventsToProcess)) { return true; }
|
||||
|
||||
#if wxUSE_EVENTLOOP_SOURCE
|
||||
virtual wxEventLoopSource *
|
||||
AddSourceForFD(int fd, wxEventLoopSourceHandler *handler, int flags);
|
||||
#endif // wxUSE_EVENTLOOP_SOURCE
|
||||
|
||||
protected:
|
||||
virtual void OnNextIteration();
|
||||
|
||||
|
Reference in New Issue
Block a user