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

View File

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