mirror of
https://github.com/xcp-ng/xenadmin.git
synced 2024-11-23 20:36:33 +01:00
CA-188554: XenCenter Error Uncaught exception System.NullReferenceException
Fixed the exception that was caused by a missing null reference check and also the fact that the license status had to be watched only for pools and hosts, so added a check before starting watching the license status of the IXenObject (on GeneralTabPage) Signed-off-by: Gabor Apati-Nagy <gabor.apati-nagy@citrix.com>
This commit is contained in:
parent
091372470f
commit
2e8e7afb7e
@ -48,7 +48,7 @@ namespace XenAdmin.TabPages
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Status != null && Status.LicencedHost != null && Status.LicenseExpiresIn.TotalDays < 3653)
|
||||
if (Status != null && Status.LicencedHost != null && Status.LicenseExpiresIn != null && Status.LicenseExpiresIn.TotalDays < 3653)
|
||||
return HelpersGUI.DateTimeToString(Status.LicencedHost.LicenseExpiryUTC.ToLocalTime(),
|
||||
Messages.DATEFORMAT_DMY_LONG, true);
|
||||
|
||||
|
4
XenAdmin/TabPages/GeneralTabPage.Designer.cs
generated
4
XenAdmin/TabPages/GeneralTabPage.Designer.cs
generated
@ -15,7 +15,9 @@ namespace XenAdmin.TabPages
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
licenseStatus.Dispose();
|
||||
if (licenseStatus != null)
|
||||
licenseStatus.Dispose();
|
||||
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
|
@ -96,19 +96,27 @@ namespace XenAdmin.TabPages
|
||||
|
||||
private void licenseStatus_ItemUpdated(object sender, EventArgs e)
|
||||
{
|
||||
if (pdSectionLicense == null)
|
||||
if (pdSectionLicense == null || licenseStatus == null)
|
||||
return;
|
||||
|
||||
GeneralTabLicenseStatusStringifier ss = new GeneralTabLicenseStatusStringifier(licenseStatus);
|
||||
Program.Invoke(Program.MainWindow, () => pdSectionLicense.UpdateEntryValueWithKey(
|
||||
FriendlyName("host.license_params-expiry"),
|
||||
ss.ExpiryDate,
|
||||
ss.ShowExpiryDate));
|
||||
Program.Invoke(Program.MainWindow, () =>
|
||||
{
|
||||
if (pdSectionLicense != null)
|
||||
pdSectionLicense.UpdateEntryValueWithKey(
|
||||
FriendlyName("host.license_params-expiry"),
|
||||
ss.ExpiryDate,
|
||||
ss.ShowExpiryDate);
|
||||
});
|
||||
|
||||
Program.Invoke(Program.MainWindow, () => pdSectionLicense.UpdateEntryValueWithKey(
|
||||
Messages.LICENSE_STATUS,
|
||||
ss.ExpiryStatus,
|
||||
true));
|
||||
Program.Invoke(Program.MainWindow, () =>
|
||||
{
|
||||
if (pdSectionLicense != null)
|
||||
pdSectionLicense.UpdateEntryValueWithKey(
|
||||
Messages.LICENSE_STATUS,
|
||||
ss.ExpiryStatus,
|
||||
true);
|
||||
});
|
||||
}
|
||||
|
||||
void s_contentReceivedFocus(PDSection s)
|
||||
@ -158,7 +166,11 @@ namespace XenAdmin.TabPages
|
||||
if (value == null)
|
||||
return;
|
||||
|
||||
SetupAnStartLicenseStatus(value);
|
||||
UnregisterLicenseStatusUpdater();
|
||||
|
||||
if (value is Host || value is Pool)
|
||||
SetupAndStartLicenseStatus(value);
|
||||
|
||||
if (xenObject != value)
|
||||
{
|
||||
UnregisterHandlers();
|
||||
@ -179,13 +191,21 @@ namespace XenAdmin.TabPages
|
||||
}
|
||||
}
|
||||
|
||||
private void SetupAnStartLicenseStatus(IXenObject xo)
|
||||
private void SetupAndStartLicenseStatus(IXenObject xo)
|
||||
{
|
||||
System.Diagnostics.Debug.Assert(xo is Host || xo is Pool);
|
||||
|
||||
licenseStatus = new LicenseStatus(xo);
|
||||
licenseStatus.ItemUpdated += licenseStatus_ItemUpdated;
|
||||
licenseStatus.BeginUpdate();
|
||||
}
|
||||
|
||||
private void UnregisterLicenseStatusUpdater()
|
||||
{
|
||||
if (licenseStatus != null)
|
||||
licenseStatus.ItemUpdated -= licenseStatus_ItemUpdated;
|
||||
}
|
||||
|
||||
void s_ExpandedEventHandler(PDSection pdSection)
|
||||
{
|
||||
if (pdSection != null)
|
||||
@ -368,7 +388,7 @@ namespace XenAdmin.TabPages
|
||||
// Atm we are rebuilding on almost any property changed event.
|
||||
// As long as we are just clearing and readding the rows in the PDSections this seems to be super quick.
|
||||
// If it gets slower we should update specific boxes for specific property changes.
|
||||
if (licenseStatus.Updated)
|
||||
if (licenseStatus != null && licenseStatus.Updated)
|
||||
licenseStatus.BeginUpdate();
|
||||
BuildList();
|
||||
EnableDisableEdit();
|
||||
|
@ -195,7 +195,7 @@ namespace XenAPI
|
||||
{
|
||||
get
|
||||
{
|
||||
if (license_params.ContainsKey("expiry"))
|
||||
if (license_params != null && license_params.ContainsKey("expiry"))
|
||||
return TimeUtil.ParseISO8601DateTime(license_params["expiry"]);
|
||||
return new DateTime(2030, 1, 1);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user