Index: TortoiseMerge/MainFrm.cpp
===================================================================
--- TortoiseMerge/MainFrm.cpp	(revision 21281)
+++ TortoiseMerge/MainFrm.cpp	(working copy)
@@ -998,12 +998,12 @@
 {
     CViewData * pViewData = NULL;
     CFileTextLines * pOriginFile = &m_Data.m_arBaseFile;
-    if ((m_pwndBottomView)&&(m_pwndBottomView->IsWindowVisible()))
+    if (IsViewGood(m_pwndBottomView))
     {
         pViewData = m_pwndBottomView->m_pViewData;
         Invalidate();
     }
-    else if ((m_pwndRightView)&&(m_pwndRightView->IsWindowVisible()))
+    else if (IsViewGood(m_pwndRightView))
     {
         pViewData = m_pwndRightView->m_pViewData;
         if (m_Data.IsYourFileInUse())
@@ -1213,21 +1213,15 @@
     BOOL bEnable = FALSE;
     if (m_Data.m_mergedFile.InUse())
     {
-        if (m_pwndBottomView)
+        if (IsViewGood(m_pwndBottomView)&&(m_pwndBottomView->m_pViewData))
         {
-            if ((m_pwndBottomView->IsWindowVisible())&&(m_pwndBottomView->m_pViewData))
+            bEnable = TRUE;
+        } else if (IsViewGood(m_pwndRightView)&&(m_pwndRightView->m_pViewData))
+            if (m_pwndRightView->IsModified() || (m_Data.m_yourFile.GetWindowName().Right(9).Compare(_T(": patched"))==0))
             {
                 bEnable = TRUE;
             }
         }
-        if (m_pwndRightView)
-        {
-            if ((m_pwndRightView->IsWindowVisible())&&(m_pwndRightView->m_pViewData))
-            {
-                if (m_pwndRightView->IsModified() || (m_Data.m_yourFile.GetWindowName().Right(9).Compare(_T(": patched"))==0))
-                    bEnable = TRUE;
-            }
-        }
     }
     pCmdUI->Enable(bEnable);
 }
@@ -1235,20 +1229,12 @@
 void CMainFrame::OnUpdateFileSaveAs(CCmdUI *pCmdUI)
 {
     BOOL bEnable = FALSE;
-    if (m_pwndBottomView)
+    if (IsViewGood(m_pwndBottomView)&&(m_pwndBottomView->m_pViewData))
     {
-        if ((m_pwndBottomView->IsWindowVisible())&&(m_pwndBottomView->m_pViewData))
-        {
-            bEnable = TRUE;
-        }
+        bEnable = TRUE;
+    } else if (IsViewGood(m_pwndRightView)&&(m_pwndRightView->m_pViewData))
+        bEnable = TRUE;
     }
-    if (m_pwndRightView)
-    {
-        if ((m_pwndRightView->IsWindowVisible())&&(m_pwndRightView->m_pViewData))
-        {
-            bEnable = TRUE;
-        }
-    }
     pCmdUI->Enable(bEnable);
 }
 
@@ -1256,10 +1242,9 @@
 {
     pCmdUI->SetCheck(!m_bOneWay);
     BOOL bEnable = TRUE;
-    if (m_pwndBottomView)
+    if (IsViewGood(m_pwndBottomView))
     {
-        if (m_pwndBottomView->IsWindowVisible())
-            bEnable = FALSE;
+        bEnable = FALSE;
     }
     pCmdUI->Enable(bEnable);
 }
@@ -1373,11 +1358,11 @@
     m_pFindDialog = new CFindDlg();
     m_pFindDialog->Create(this);
     CString markedWord;
-    if (m_pwndLeftView && m_pwndLeftView->IsWindowVisible())
+    if (IsViewGood(m_pwndLeftView))
         markedWord = m_pwndLeftView->GetMarkedWord();
-    if (markedWord.IsEmpty() && m_pwndRightView && m_pwndRightView->IsWindowVisible())
+    if (markedWord.IsEmpty() && IsViewGood(m_pwndRightView))
         markedWord = m_pwndRightView->GetMarkedWord();
-    if (markedWord.IsEmpty() && m_pwndBottomView && m_pwndBottomView->IsWindowVisible())
+    if (markedWord.IsEmpty() && IsViewGood(m_pwndBottomView))
         markedWord = m_pwndBottomView->GetMarkedWord();
 
     m_pFindDialog->SetFindString(markedWord);
@@ -1684,7 +1669,7 @@
 
 void CMainFrame::OnUpdateEditUseleftblock(CCmdUI *pCmdUI)
 {
-    pCmdUI->Enable(m_pwndRightView && m_pwndRightView->IsWindowVisible() && m_pwndRightView->HasCaret() && m_pwndRightView->HasSelection());
+    pCmdUI->Enable(IsViewGood(m_pwndRightView) && m_pwndRightView->HasCaret() && m_pwndRightView->HasSelection());
 }
 
 void CMainFrame::OnEditUseleftfile()
@@ -1697,7 +1682,7 @@
 
 void CMainFrame::OnUpdateEditUseleftfile(CCmdUI *pCmdUI)
 {
-    pCmdUI->Enable(m_pwndRightView && m_pwndRightView->IsWindowVisible() && m_pwndRightView->HasCaret());
+    pCmdUI->Enable(IsViewGood(m_pwndRightView) && m_pwndRightView->HasCaret());
 }
 
 void CMainFrame::OnEditUseblockfromleftbeforeright()
@@ -1808,12 +1793,9 @@
     BOOL bEnable = FALSE;
     if ((!m_bReadOnly)&&(m_Data.m_mergedFile.InUse()))
     {
-        if (m_pwndBottomView)
+        if (IsViewGood(m_pwndBottomView)&&(m_pwndBottomView->m_pViewData))
         {
-            if ((m_pwndBottomView->IsWindowVisible())&&(m_pwndBottomView->m_pViewData))
-            {
-                bEnable = TRUE;
-            }
+            bEnable = TRUE;
         }
     }
     pCmdUI->Enable(bEnable);
@@ -1827,12 +1809,9 @@
     // now check if the file has already been saved and if not, save it.
     if (m_Data.m_mergedFile.InUse())
     {
-        if (m_pwndBottomView)
+        if (IsViewGood(m_pwndBottomView)&&(m_pwndBottomView->m_pViewData))
         {
-            if ((m_pwndBottomView->IsWindowVisible())&&(m_pwndBottomView->m_pViewData))
-            {
-                FileSave(false);
-            }
+            FileSave(false);
         }
     }
     MarkAsResolved();
@@ -1842,7 +1821,7 @@
 {
     if (m_bReadOnly)
         return FALSE;
-    if ((!m_pwndBottomView)||(!m_pwndBottomView->IsWindowVisible()))
+    if (!IsViewGood(m_pwndBottomView))
         return FALSE;
 
     CString cmd = _T("/command:resolve /path:\"");
@@ -2009,15 +1988,13 @@
 void CMainFrame::OnUpdateViewSwitchleft(CCmdUI *pCmdUI)
 {
     BOOL bEnable = TRUE;
-    if (m_pwndBottomView)
+    if (IsViewGood(m_pwndBottomView))
     {
-        if (m_pwndBottomView->IsWindowVisible())
-            bEnable = FALSE;
+        bEnable = FALSE;
     }
     pCmdUI->Enable(bEnable);
 }
 
-
 void CMainFrame::OnUpdateViewShowfilelist(CCmdUI *pCmdUI)
 {
     if (m_dlgFilePatches.HasFiles())
@@ -2154,13 +2131,18 @@
     return HasUnsavedEdits(m_pwndBottomView) || HasUnsavedEdits(m_pwndRightView);
 }
 
-bool CMainFrame::HasUnsavedEdits(const CBaseView* view) const
+bool CMainFrame::HasUnsavedEdits(const CBaseView* view)
 {
     if(view == 0)
         return false;
     return view->IsModified();
 }
 
+bool CMainFrame::IsViewGood(const CBaseView* view)
+{
+    return CBaseView::IsViewGood(view);
+}
+
 void CMainFrame::OnViewInlinediffword()
 {
     m_bInlineWordDiff = !m_bInlineWordDiff;
@@ -2184,8 +2166,7 @@
 
 void CMainFrame::OnUpdateViewInlinediffword(CCmdUI *pCmdUI)
 {
-    pCmdUI->Enable(m_pwndLeftView && m_pwndLeftView->IsWindowVisible() &&
-        m_pwndRightView && m_pwndRightView->IsWindowVisible());
+    pCmdUI->Enable(IsViewGood(m_pwndLeftView) && IsViewGood(m_pwndRightView));
     pCmdUI->SetCheck(m_bInlineWordDiff);
 }
 
@@ -2194,11 +2175,11 @@
     // "create unified diff file" is only available if two files
     // are diffed, not three.
     bool bEnabled = true;
-    if ((m_pwndLeftView == NULL)||(!m_pwndLeftView->IsWindowVisible()))
+    if (!IsViewGood(m_pwndLeftView))
         bEnabled = false;
-    if ((m_pwndRightView == NULL)||(!m_pwndRightView->IsWindowVisible()))
+    else if (!IsViewGood(m_pwndRightView))
         bEnabled = false;
-    if ((m_pwndBottomView)&&(m_pwndBottomView->IsWindowVisible()))
+    else if (IsViewGood(m_pwndBottomView)) //no negation here
         bEnabled = false;
     pCmdUI->Enable(bEnabled);
 }
@@ -2311,10 +2292,9 @@
 {
     pCmdUI->SetCheck(m_bViewMovedBlocks);
     BOOL bEnable = TRUE;
-    if (m_pwndBottomView)
+    if (IsViewGood(m_pwndBottomView))
     {
-        if (m_pwndBottomView->IsWindowVisible())
-            bEnable = FALSE;
+        bEnable = FALSE;
     }
     pCmdUI->Enable(bEnable);
 }
Index: TortoiseMerge/MainFrm.h
===================================================================
--- TortoiseMerge/MainFrm.h	(revision 21281)
+++ TortoiseMerge/MainFrm.h	(working copy)
@@ -170,7 +170,8 @@
     void            OnViewTextFoldUnfold();
     void            OnViewTextFoldUnfold(CBaseView* view);
     bool            HasUnsavedEdits() const;
-    bool            HasUnsavedEdits(const CBaseView* view) const;
+    static bool     HasUnsavedEdits(const CBaseView* view);
+    static bool	    IsViewGood(const CBaseView* view);
 
 protected:
     CMFCMenuBar     m_wndMenuBar;
