From 8bec024315d74b0b426c4918137bda0eda31bcc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tiago=20Concei=C3=A7=C3=A3o?= Date: Mon, 14 Sep 2020 21:55:04 +0100 Subject: [PATCH] Fix ctb and pws * (Fix) ctb and pws: Renders a bad file after save, this was introduced with cancelled saves feature * (Fix) When cancel a file convertion, it now deletes the target file --- CHANGELOG.md | 6 ++++-- UVtools.Core/FileFormats/ChituboxFile.cs | 6 +++--- UVtools.Core/FileFormats/FileFormat.cs | 1 + UVtools.Core/FileFormats/PWSFile.cs | 2 +- UVtools.GUI/FrmMain.cs | 7 +++++-- 5 files changed, 14 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0bb1244..0084dcc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,12 @@ # Changelog -## ?/09/2020 - v0.8.2.1 +## 14/09/2020 - v0.8.2.1 -* (Improvement) When unable to convert a format from SL1 to other, advice users to check used printer on PrusaSlicer +* (Improvement) When unable to convert a format from SL1 to other, advice users to check used printer on PrusaSlicer (#60) * (Improvement) Information on "Install profiles on PrusaSlicer" (#60) * (Fix) LGS: Change resolution tool was defining wrong Y +* (Fix) ctb and pws: Renders a bad file after save, this was introduced with cancelled saves feature +* (Fix) When cancel a file convertion, it now deletes the target file ## 13/09/2020 - v0.8.2.0 diff --git a/UVtools.Core/FileFormats/ChituboxFile.cs b/UVtools.Core/FileFormats/ChituboxFile.cs index 0bc1044..0b12ba2 100644 --- a/UVtools.Core/FileFormats/ChituboxFile.cs +++ b/UVtools.Core/FileFormats/ChituboxFile.cs @@ -26,8 +26,8 @@ namespace UVtools.Core.FileFormats public class ChituboxFile : FileFormat { #region Constants - private const uint MAGIC_CBDDLP = 0x12FD0019; - private const uint MAGIC_CBT = 0x12FD0086; + private const uint MAGIC_CBDDLP = 0x12FD0019; // 318570521 + private const uint MAGIC_CBT = 0x12FD0086; // 318570630 private const ushort REPEATRGB15MASK = 0x20; private const byte RLE8EncodingLimit = 0x7d; // 125; @@ -1139,7 +1139,7 @@ namespace UVtools.Core.FileFormats base.Encode(fileFullPath, progress); LayersHash.Clear(); - HeaderSettings.Magic = fileFullPath.EndsWith(".ctb") ? MAGIC_CBT : MAGIC_CBDDLP; + HeaderSettings.Magic = fileFullPath.EndsWith(".ctb") || fileFullPath.EndsWith($".ctb{TemporaryFileAppend}") ? MAGIC_CBT : MAGIC_CBDDLP; HeaderSettings.PrintParametersSize = (uint)Helpers.Serializer.SizeOf(PrintParametersSettings); diff --git a/UVtools.Core/FileFormats/FileFormat.cs b/UVtools.Core/FileFormats/FileFormat.cs index ea4d18a..b93eb2b 100644 --- a/UVtools.Core/FileFormats/FileFormat.cs +++ b/UVtools.Core/FileFormats/FileFormat.cs @@ -26,6 +26,7 @@ namespace UVtools.Core.FileFormats /// public abstract class FileFormat : IFileFormat, IDisposable, IEquatable, IEnumerable { + public const string TemporaryFileAppend = ".tmp"; #region Enums /// diff --git a/UVtools.Core/FileFormats/PWSFile.cs b/UVtools.Core/FileFormats/PWSFile.cs index 85104cb..56a1a7b 100644 --- a/UVtools.Core/FileFormats/PWSFile.cs +++ b/UVtools.Core/FileFormats/PWSFile.cs @@ -876,7 +876,7 @@ namespace UVtools.Core.FileFormats public override object[] Configs => new object[] { FileMarkSettings, HeaderSettings, PreviewSettings, LayersDefinition }; - public LayerRleFormat LayerFormat => FileFullPath.EndsWith(".pws") ? LayerRleFormat.PWS : LayerRleFormat.PW0; + public LayerRleFormat LayerFormat => FileFullPath.EndsWith(".pws") || FileFullPath.EndsWith($".pws{TemporaryFileAppend}") ? LayerRleFormat.PWS : LayerRleFormat.PW0; #endregion diff --git a/UVtools.GUI/FrmMain.cs b/UVtools.GUI/FrmMain.cs index bb76ccf..e989c36 100644 --- a/UVtools.GUI/FrmMain.cs +++ b/UVtools.GUI/FrmMain.cs @@ -1424,7 +1424,10 @@ namespace UVtools.GUI } catch (OperationCanceledException) { - + if (File.Exists(dialog.FileName)) + { + File.Delete(dialog.FileName); + } } catch (Exception ex) { @@ -2013,7 +2016,7 @@ namespace UVtools.GUI } var oldFile = SlicerFile.FileFullPath; - var tempFile = filepath + ".tmp"; + var tempFile = filepath + FileFormat.TemporaryFileAppend; DisableGUI(); FrmLoading.SetDescription($"Saving {Path.GetFileName(filepath)}");