VOID_DataLogger: Now caching file name (probably needs to be cleared when vessels change) and added some debug messages.
[VOID.git] / VOID_DataLogger.cs
blob:a/VOID_DataLogger.cs -> blob:b/VOID_DataLogger.cs
--- a/VOID_DataLogger.cs
+++ b/VOID_DataLogger.cs
@@ -101,7 +101,7 @@
 				if (this._fileName == null || this._fileName == string.Empty)
 				{
 					this._fileName = KSP.IO.IOUtils.GetFilePathFor(
-						typeof(VOID_Core),
+						typeof(VOIDCore),
 						string.Format(
 							"{0}_{1}",
 							this.vessel.vesselName,
@@ -425,7 +425,7 @@
 
 			logger.AppendFormat("Cleaning up file {0}...", this.fileName);
 
-			if (this.csvBytes.Count > 0)
+			if (this.csvBytes != null && this.csvBytes.Count > 0)
 			{
 				logger.Append(" Writing remaining data...");
 				this.AsyncWriteData();
@@ -454,7 +454,7 @@
 
 		public VOID_DataLogger()
 		{
-			this._Name = "CSV Data Logger";
+			this.Name = "CSV Data Logger";
 
 			this.loggingActive = false;
 			this.firstWrite = true;
@@ -466,6 +466,11 @@
 
 			this.WindowPos.x = Screen.width - 520f;
 			this.WindowPos.y = 85f;
+
+			this.core.onApplicationQuit += delegate(object sender)
+			{
+				this.CloseFileIfOpen();
+			};
 		}
 
 		~VOID_DataLogger()