From 95fc69e7f83bbc01e802c4a50df2bc13f5c50a84 Mon Sep 17 00:00:00 2001 From: Lars Brubaker Date: Fri, 21 Oct 2016 17:09:53 -0700 Subject: [PATCH] Always call UserChanged when ChangeCloudSyncStatus Don't clear the LastSessionUserName It should only be used in the name field of the login screen and nowhere else. --- ApplicationView/MainApplicationWidget.cs | 11 +++++------ PartPreviewWindow/ViewGcodeWidget.cs | 2 +- Utilities/AuthenticationData.cs | 1 - 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/ApplicationView/MainApplicationWidget.cs b/ApplicationView/MainApplicationWidget.cs index 88f5d859f..ca67c0b0d 100644 --- a/ApplicationView/MainApplicationWidget.cs +++ b/ApplicationView/MainApplicationWidget.cs @@ -521,15 +521,14 @@ namespace MatterHackers.MatterControl CloudSyncStatusChanged.CallEvents(this, new CloudSyncEventArgs() { IsAuthenticated = userAuthenticated }); // Only fire UserChanged if it actually happened - prevents runaway positive feedback loop - if (AuthenticationData.Instance.ActiveSessionUsername != AuthenticationData.Instance.LastSessionUsername) + if (!string.IsNullOrEmpty(AuthenticationData.Instance.ActiveSessionUsername) + && AuthenticationData.Instance.ActiveSessionUsername != AuthenticationData.Instance.LastSessionUsername) { // only set it if it is an actual user name - if (!string.IsNullOrEmpty(AuthenticationData.Instance.ActiveSessionUsername)) - { - AuthenticationData.Instance.LastSessionUsername = AuthenticationData.Instance.ActiveSessionUsername; - } - UserChanged(); + AuthenticationData.Instance.LastSessionUsername = AuthenticationData.Instance.ActiveSessionUsername; } + + UserChanged(); } // Called after every startup and at the completion of every authentication change diff --git a/PartPreviewWindow/ViewGcodeWidget.cs b/PartPreviewWindow/ViewGcodeWidget.cs index 76ad9e788..e724f8439 100644 --- a/PartPreviewWindow/ViewGcodeWidget.cs +++ b/PartPreviewWindow/ViewGcodeWidget.cs @@ -356,7 +356,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow //using (new PerformanceTimer("GCode Timer", "Render")) { - gCodeRenderer.Render(graphics2D, renderInfo); + gCodeRenderer?.Render(graphics2D, renderInfo); } } } diff --git a/Utilities/AuthenticationData.cs b/Utilities/AuthenticationData.cs index edc6c1b2b..d1b5aef0b 100644 --- a/Utilities/AuthenticationData.cs +++ b/Utilities/AuthenticationData.cs @@ -64,7 +64,6 @@ namespace MatterHackers.MatterControl this.ActiveSessionUsername = null; this.ActiveSessionEmail = null; this.ActiveClientToken = null; - this.LastSessionUsername = null; ApplicationController.Instance.ChangeCloudSyncStatus(userAuthenticated: false, reason: "Session Cleared".Localize()); SessionUpdateTrigger.CallEvents(null, null);