From 19210eea93cabec81b88c9294e5d500dad773774 Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Thu, 5 Jun 2003 12:03:47 +0000 Subject: [PATCH] Fixed bug [ 749471 ] wxDocument with no command processor git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@20932 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/docview.cpp | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/src/common/docview.cpp b/src/common/docview.cpp index 50b2d7cd8c..b67efc1a2c 100644 --- a/src/common/docview.cpp +++ b/src/common/docview.cpp @@ -932,22 +932,26 @@ void wxDocManager::OnPreview(wxCommandEvent& WXUNUSED(event)) #endif // wxUSE_PRINTING_ARCHITECTURE } -void wxDocManager::OnUndo(wxCommandEvent& WXUNUSED(event)) +void wxDocManager::OnUndo(wxCommandEvent& event) { wxDocument *doc = GetCurrentDocument(); if (!doc) return; if (doc->GetCommandProcessor()) doc->GetCommandProcessor()->Undo(); + else + event.Skip(); } -void wxDocManager::OnRedo(wxCommandEvent& WXUNUSED(event)) +void wxDocManager::OnRedo(wxCommandEvent& event) { wxDocument *doc = GetCurrentDocument(); if (!doc) return; if (doc->GetCommandProcessor()) doc->GetCommandProcessor()->Redo(); + else + event.Skip(); } // Handlers for UI update commands @@ -989,17 +993,29 @@ void wxDocManager::OnUpdateFileSaveAs(wxUpdateUIEvent& event) void wxDocManager::OnUpdateUndo(wxUpdateUIEvent& event) { wxDocument *doc = GetCurrentDocument(); - event.Enable( (doc && doc->GetCommandProcessor() && doc->GetCommandProcessor()->CanUndo()) ); - if (doc && doc->GetCommandProcessor()) + if (!doc) + event.Enable(FALSE); + else if (!doc->GetCommandProcessor()) + event.Skip(); + else + { + event.Enable( doc->GetCommandProcessor()->CanUndo() ); doc->GetCommandProcessor()->SetMenuStrings(); + } } void wxDocManager::OnUpdateRedo(wxUpdateUIEvent& event) { wxDocument *doc = GetCurrentDocument(); - event.Enable( (doc && doc->GetCommandProcessor() && doc->GetCommandProcessor()->CanRedo()) ); - if (doc && doc->GetCommandProcessor()) + if (!doc) + event.Enable(FALSE); + else if (!doc->GetCommandProcessor()) + event.Skip(); + else + { + event.Enable( doc->GetCommandProcessor()->CanRedo() ); doc->GetCommandProcessor()->SetMenuStrings(); + } } void wxDocManager::OnUpdatePrint(wxUpdateUIEvent& event)