1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-12 21:34:11 +02:00

Fix 'Dont Save' on Secondary Windows

When you select 'Dont Save' on the close dialog of secondary windows,
the projectSource is left with changes and no SourceViewPanel, and then
VerifyModifiedBuffers will fail. This fix uses refactored code from
CloseDocument, 'RevertSourceViewPanel', to revert changes on close.
This commit is contained in:
Joseph Battelle 2021-02-01 18:20:12 -08:00
parent 21f2edd8b0
commit 1f772f685e

View file

@ -1273,6 +1273,12 @@ namespace IDE
});
aDialog.AddButton("Don't Save", new (evt) =>
{
var _this = this;
WithSourceViewPanelsOf(window, scope [&] (sourceViewPanel) =>
{
if (sourceViewPanel.HasUnsavedChanges())
_this.RevertSourceViewPanel(sourceViewPanel);
});
mMainWindow.SetForeground();
window.Close(true);
});
@ -6477,21 +6483,7 @@ namespace IDE
aDialog.PopupWindow(mMainWindow);
}
public void CloseDocument(Widget documentPanel)
{
bool hasFocus = false;
var sourceViewPanel = documentPanel as SourceViewPanel;
if ((documentPanel.mWidgetWindow != null) && (documentPanel.mWidgetWindow.mFocusWidget != null))
{
if (documentPanel.mWidgetWindow.mFocusWidget.HasParent(documentPanel))
hasFocus = true;
}
/*if (sourceViewPanel != null)
hasFocus = sourceViewPanel.mEditWidget.mHasFocus;*/
if ((sourceViewPanel != null) && (sourceViewPanel.HasUnsavedChanges()))
void RevertSourceViewPanel(SourceViewPanel sourceViewPanel)
{
// When we close a Beef file that has modified text, we need to revert by
// reparsing from the actual source file
@ -6546,6 +6538,23 @@ namespace IDE
}
}
public void CloseDocument(Widget documentPanel)
{
bool hasFocus = false;
var sourceViewPanel = documentPanel as SourceViewPanel;
if ((documentPanel.mWidgetWindow != null) && (documentPanel.mWidgetWindow.mFocusWidget != null))
{
if (documentPanel.mWidgetWindow.mFocusWidget.HasParent(documentPanel))
hasFocus = true;
}
/*if (sourceViewPanel != null)
hasFocus = sourceViewPanel.mEditWidget.mHasFocus;*/
if ((sourceViewPanel != null) && (sourceViewPanel.HasUnsavedChanges()))
RevertSourceViewPanel(sourceViewPanel);
DarkTabbedView tabbedView = null;
DarkTabbedView.DarkTabButton tabButton = null;
WithTabs(scope [&] (tab) =>