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

@@ -256,6 +256,7 @@ protected:
event
(
wxFSW_EVENT_WARNING,
wxFSW_WARNING_GENERAL,
wxString::Format
(
_("Unexpected event for \"%s\": no "
@@ -279,8 +280,19 @@ protected:
// check out for error/warning condition
if (flags & wxFSW_EVENT_WARNING || flags & wxFSW_EVENT_ERROR)
{
wxString errMsg = GetErrorDescription(nativeFlags);
wxFileSystemWatcherEvent event(flags, errMsg);
wxFSWWarningType warningType;
if ( flags & wxFSW_EVENT_WARNING )
{
warningType = nativeFlags & IN_Q_OVERFLOW
? wxFSW_WARNING_OVERFLOW
: wxFSW_WARNING_GENERAL;
}
else // It's an error, not a warning.
{
warningType = wxFSW_WARNING_NONE;
}
wxFileSystemWatcherEvent event(flags, warningType);
SendEvent(event);
return;
}
@@ -293,6 +305,7 @@ protected:
event
(
wxFSW_EVENT_WARNING,
wxFSW_WARNING_GENERAL,
wxString::Format
(
_("Invalid inotify event for \"%s\""),
@@ -628,22 +641,6 @@ protected:
return -1;
}
/**
* Returns error description for specified inotify mask
*/
static const wxString GetErrorDescription(int flag)
{
switch ( flag )
{
case IN_Q_OVERFLOW:
return _("Event queue overflowed");
}
// never reached
wxFAIL_MSG(wxString::Format("Unknown inotify event mask %u", flag));
return wxEmptyString;
}
wxFSWSourceHandler* m_handler; // handler for inotify event source
wxFSWatchEntryDescriptors m_watchMap; // inotify wd=>wxFSWatchEntry* map
wxArrayInt m_staleDescriptors; // stores recently-removed watches