Apply suggestions from code review

This commit is contained in:
Vadim Zeitlin 2021-02-05 22:03:35 +01:00 committed by Tobias Taschner
parent d11ab7f751
commit e88b55bfe1
No known key found for this signature in database
GPG Key ID: AE6ECD71294F87FD
3 changed files with 24 additions and 20 deletions

View File

@ -78,7 +78,7 @@ wxWebViewZoom wxWebView::GetZoom() const
}
// to shut up compilers, this can never be reached logically
wxASSERT(false);
wxFAIL_MSG("unreachable");
return wxWEBVIEW_ZOOM_MEDIUM;
}
@ -106,9 +106,6 @@ void wxWebView::SetZoom(wxWebViewZoom zoom)
case wxWEBVIEW_ZOOM_LARGEST:
SetZoomFactor(1.6f);
break;
default:
wxASSERT(false);
}
}

View File

@ -741,14 +741,18 @@ bool wxWebViewFactoryEdge::IsAvailable()
wxVersionInfo wxWebViewFactoryEdge::GetVersionInfo()
{
IsAvailable(); // Make sure ms_version string is initialized (if available)
long versions[3] = { 0, 0, 0 };
wxArrayString tokens = wxStringTokenize(wxWebViewEdgeImpl::ms_version, ". ");
for (size_t i = 0; i < 3; i++)
{
if (tokens.size() > i)
tokens[i].ToLong(&versions[i]);
}
return wxVersionInfo("Microsoft Edge WebView2", versions[0], versions[1], versions[2]);
long major = 0,
minor = 0,
micro = 0;
wxStringTokenizer tk(wxWebViewEdgeImpl::ms_version, ". ");
// Ignore the return value because if the version component is missing
// or invalid (i.e. non-numeric), the only thing we can do is to ignore
// it anyhow.
tk.GetNextToken().ToLong(&major);
tk.GetNextToken().ToLong(&minor);
tk.GetNextToken().ToLong(&micro);
return wxVersionInfo("Microsoft Edge WebView2", major, minor, micro);
}
// ----------------------------------------------------------------------------

View File

@ -58,14 +58,17 @@ wxVersionInfo wxWebViewFactoryIE::GetVersionInfo()
wxRegKey key(wxRegKey::HKLM, "Software\\Microsoft\\Internet Explorer");
wxString value;
key.QueryValue("Version", value);
long versions[3] = { 0, 0, 0 };
wxArrayString tokens = wxStringTokenize(value, ". ");
for (size_t i = 0; i < 3; i++)
{
if (tokens.size() > i)
tokens[i].ToLong(&versions[i]);
}
return wxVersionInfo("Internet Explorer", versions[0], versions[1], versions[2]);
long major = 0,
minor = 0,
micro = 0;
wxStringTokenizer tk(value, ". ");
// Ignore the return value because if the version component is missing
// or invalid (i.e. non-numeric), the only thing we can do is to ignore
// it anyhow.
tk.GetNextToken().ToLong(&major);
tk.GetNextToken().ToLong(&minor);
tk.GetNextToken().ToLong(&micro);
return wxVersionInfo("Internet Explorer", major, minor, micro);
}
//Convenience function for error conversion