Skip to content

Commit

Permalink
Show close window confirmation even when session is remembered, excep…
Browse files Browse the repository at this point in the history
…t when closing entire plugin
  • Loading branch information
MarkMpn committed Dec 4, 2024
1 parent ea007ba commit 4cd8042
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion MarkMpn.Sql4Cds.XTB/DocumentWindowBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ protected override void OnClosing(CancelEventArgs e)
{
base.OnClosing(e);

if (Modified && !Settings.Instance.RememberSession && this is ISaveableDocumentWindow saveable)
if (Modified && this is ISaveableDocumentWindow saveable)
{
using (var form = new ConfirmCloseForm(new[] { DisplayName }, true))
{
Expand Down
11 changes: 6 additions & 5 deletions MarkMpn.Sql4Cds.XTB/PluginControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -664,15 +664,16 @@ private void SaveSettings()

public override void ClosingPlugin(PluginCloseInfo info)
{
if (!ConfirmBulkClose(dockPanel.Contents.OfType<IDocumentWindow>().Cast<IDockContent>().ToArray(), info.Silent))
if (Settings.Instance.RememberSession)
{
SaveSettings();
}
else if (!ConfirmBulkClose(dockPanel.Contents.OfType<IDocumentWindow>().Cast<IDockContent>().ToArray(), info.Silent))
{
info.Cancel = true;
return;
}

if (Settings.Instance.RememberSession)
SaveSettings();

base.ClosingPlugin(info);
}

Expand Down Expand Up @@ -898,7 +899,7 @@ private bool ConfirmBulkClose(IDockContent[] documents, bool silent)
.Where(query => query.Modified)
.ToArray();

if (unsavedDocuments.Length > 0 && !Settings.Instance.RememberSession)
if (unsavedDocuments.Length > 0)
{
using (var form = new ConfirmCloseForm(unsavedDocuments.Select(query => query.DisplayName).ToArray(), !silent))
{
Expand Down

0 comments on commit 4cd8042

Please sign in to comment.