Generate events with specific wxFSW_WARNING_OVERFLOW type if applicable.

This allows the program to distinguish between some other, unspecified,
warnings and this one which can and does happen whenever too many changes
occur too quickly but which has a clearly defined work around: the state kept
inside the program just needs to be refreshed by rescanning the directory anew.

See #12847.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74950 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2013-10-07 09:58:51 +00:00
parent 1fd9d44670
commit d32895c5d8
6 changed files with 130 additions and 28 deletions

View File

@@ -231,6 +231,29 @@ bool wxIOCPThread::ReadEvents()
if (!count && !watch && !overlapped)
return false;
// if the thread got woken up but we got an empty packet it means that
// there was an overflow, too many events and not all could fit in
// the watch buffer. In this case, ReadDirectoryChangesW dumps the
// buffer.
if (!count && watch)
{
wxLogTrace(wxTRACE_FSWATCHER, "[iocp] Event queue overflowed: path=\"%s\"",
watch->GetPath());
if (watch->GetFlags() & wxFSW_EVENT_WARNING)
{
wxFileSystemWatcherEvent
overflowEvent(wxFSW_EVENT_WARNING, wxFSW_WARNING_OVERFLOW);
overflowEvent.SetPath(watch->GetPath());
SendEvent(overflowEvent);
}
// overflow is not a fatal error, we still want to get future events
// reissue the watch
(void) m_service->SetUpWatch(*watch);
return true;
}
// in case of spurious wakeup
if (!count || !watch)
return true;
@@ -283,9 +306,10 @@ void wxIOCPThread::ProcessNativeEvents(wxVector<wxEventProcessingData>& events)
int flags = Native2WatcherFlags(nativeFlags);
if (flags & wxFSW_EVENT_WARNING || flags & wxFSW_EVENT_ERROR)
{
// TODO think about this...do we ever have any errors to report?
wxString errMsg = "Error occurred";
wxFileSystemWatcherEvent event(flags, errMsg);
wxFileSystemWatcherEvent
event(flags,
flags & wxFSW_EVENT_ERROR ? wxFSW_WARNING_NONE
: wxFSW_WARNING_GENERAL);
SendEvent(event);
}
// filter out ignored events and those not asked for.