Merge branch 'version-info-revision'

Add build number to wxVersionInfo and use it for IE/Edge web view
backends versions.

Closes #22455.
This commit is contained in:
Vadim Zeitlin 2022-06-29 22:51:44 +02:00
commit 964a7d2e4f
4 changed files with 63 additions and 14 deletions

View File

@ -23,15 +23,21 @@ public:
int major = 0,
int minor = 0,
int micro = 0,
int revision = 0,
const wxString& description = wxString(),
const wxString& copyright = wxString())
: m_name(name)
, m_description(description)
, m_copyright(copyright)
{
m_major = major;
m_minor = minor;
m_micro = micro;
Init(name, major, minor, micro, revision, description, copyright);
}
// This constructor exists for backward compatibility (before the revision
// part was added).
wxVersionInfo(const wxString& name,
int major, int minor, int micro,
const wxString& description,
const wxString& copyright = wxString())
{
Init(name, major, minor, micro, 0, description, copyright);
}
// Default copy ctor, assignment operator and dtor are ok.
@ -42,6 +48,7 @@ public:
int GetMajor() const { return m_major; }
int GetMinor() const { return m_minor; }
int GetMicro() const { return m_micro; }
int GetRevision() const { return m_revision; }
wxString ToString() const
{
@ -52,8 +59,12 @@ public:
{
wxString str;
str << m_name << ' ' << GetMajor() << '.' << GetMinor();
if ( GetMicro() )
if ( GetMicro() || GetRevision() )
{
str << '.' << GetMicro();
if ( GetRevision() )
str << '.' << GetRevision();
}
return str;
}
@ -65,13 +76,28 @@ public:
const wxString& GetCopyright() const { return m_copyright; }
private:
void Init(const wxString& name,
int major, int minor, int micro, int revision,
const wxString& description,
const wxString& copyright)
{
m_name = name;
m_description = description;
m_copyright = copyright;
m_major = major;
m_minor = minor;
m_micro = micro;
m_revision = revision;
}
wxString m_name,
m_description,
m_copyright;
int m_major,
m_minor,
m_micro;
m_micro,
m_revision;
};
#endif // _WX_VERSIONINFO_H_

View File

@ -35,6 +35,9 @@ public:
@param major The major version component.
@param minor The minor version component.
@param micro The micro version component, 0 by default.
@param revision The revision version component, also known as "build
number". This component is also 0 by default and is only available
since wxWidgets 3.2.0.
@param description Free form description of this version, none by
default.
@param copyright Copyright string, none by default.
@ -43,6 +46,7 @@ public:
int major = 0,
int minor = 0,
int micro = 0,
int revision = 0,
const wxString& description = wxString(),
const wxString& copyright = wxString());
@ -70,10 +74,23 @@ public:
/**
Get the micro version, or release number.
This is the third component of the version.
@return Micro version, or release number.
*/
int GetMicro() const;
/**
Get the revision version, or build number.
This is the fourth component of the version.
@return Revision version, or build number.
@since 3.2.0
*/
int GetRevision() const;
/**
Get the string representation of this version object.
@ -87,9 +104,11 @@ public:
/**
Get the string representation.
The micro component of the version is ignored/not used if it is 0.
The micro and revision components of the version are ignored/not used
if they are both zero. If the revision component is non-zero all four
parts will be used even if the micro component is zero.
@return The version string in the form "name major.minor[.micro]".
@return The version string in the form "name major.minor[.micro[.revision]]".
*/
wxString GetVersionString() const;

View File

@ -980,7 +980,8 @@ wxVersionInfo wxWebViewFactoryEdge::GetVersionInfo()
{
long major = 0,
minor = 0,
micro = 0;
micro = 0,
revision = 0;
if (wxWebViewEdgeImpl::Initialize())
{
@ -996,10 +997,11 @@ wxVersionInfo wxWebViewFactoryEdge::GetVersionInfo()
tk.GetNextToken().ToLong(&major);
tk.GetNextToken().ToLong(&minor);
tk.GetNextToken().ToLong(&micro);
tk.GetNextToken().ToLong(&revision);
}
}
return wxVersionInfo("Microsoft Edge WebView2", major, minor, micro);
return wxVersionInfo("Microsoft Edge WebView2", major, minor, micro, revision);
}
// ----------------------------------------------------------------------------

View File

@ -60,7 +60,8 @@ wxVersionInfo wxWebViewFactoryIE::GetVersionInfo()
key.QueryValue("Version", value);
long major = 0,
minor = 0,
micro = 0;
micro = 0,
revision = 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
@ -68,7 +69,8 @@ wxVersionInfo wxWebViewFactoryIE::GetVersionInfo()
tk.GetNextToken().ToLong(&major);
tk.GetNextToken().ToLong(&minor);
tk.GetNextToken().ToLong(&micro);
return wxVersionInfo("Internet Explorer", major, minor, micro);
tk.GetNextToken().ToLong(&revision);
return wxVersionInfo("Internet Explorer", major, minor, micro, revision);
}
//Convenience function for error conversion