Rewrite switch on wxTextBufferOpenMode to be exhaustive

Get rid of the default clause to allow the compiler to warn us if ever add new
elements to this enum.

No real changes.
This commit is contained in:
Vadim Zeitlin 2016-02-13 13:52:13 +01:00
parent fe850fccc5
commit 0d7f51098d

View File

@ -58,23 +58,26 @@ bool wxTextFile::OnExists() const
bool wxTextFile::OnOpen(const wxString &strBufferName, wxTextBufferOpenMode openMode)
{
wxFile::OpenMode fileOpenMode;
wxFile::OpenMode fileOpenMode = wxFile::read_write;
switch ( openMode )
{
default:
wxFAIL_MSG( wxT("unknown open mode in wxTextFile::Open") );
wxFALLTHROUGH;
case ReadAccess :
case ReadAccess:
fileOpenMode = wxFile::read;
break;
case WriteAccess :
case WriteAccess:
fileOpenMode = wxFile::write;
break;
}
if ( fileOpenMode == wxFile::read_write )
{
// This must mean it hasn't been initialized in the switch above.
wxFAIL_MSG( wxT("unknown open mode in wxTextFile::Open") );
return false;
}
return m_file.Open(strBufferName, fileOpenMode);
}