瀏覽代碼

ENH: add a check to avoid quitting before rebuilding

Bill Hoffman 24 年之前
父節點
當前提交
ae25b63b6a

+ 18 - 0
Source/MFCDialog/CMakeSetupDialog.cpp

@@ -108,6 +108,7 @@ BEGIN_MESSAGE_MAP(CMakeSetupDialog, CDialog)
   ON_WM_SYSCOMMAND()
   ON_WM_PAINT()
   ON_WM_QUERYDRAGICON()
+  ON_BN_CLICKED(IDOK, OnOK)
   ON_BN_CLICKED(IDC_BuildProjects, OnBuildProjects)
   ON_CBN_EDITCHANGE(IDC_WhereBuild, OnChangeWhereBuild)
   ON_CBN_EDITCHANGE(IDC_WhereSource, OnChangeWhereSource)
@@ -444,6 +445,7 @@ void CMakeSetupDialog::OnBuildProjects()
   m_BuildPathChanged = false;
   // put the cursor back
   ::SetCursor(LoadCursor(NULL, IDC_ARROW));
+  m_CacheEntriesList.ClearDirty();
 }
 
 
@@ -658,3 +660,19 @@ void CMakeSetupDialog::OnGetMinMaxInfo( MINMAXINFO FAR* lpMMI )
   lpMMI->ptMinTrackSize.y = 272;
 }
 
+void CMakeSetupDialog::OnOK()
+{
+  if(m_CacheEntriesList.IsDirty())
+    {
+    if(MessageBox("You have changed options but not rebuilt, "
+		  "are you sure you want to exit?", "Confirm Exit",
+		  MB_YESNO) == IDYES)
+      {
+      CDialog::OnOK();
+      }
+    }
+  else
+    {
+    CDialog::OnOK();
+    }
+}

+ 1 - 0
Source/MFCDialog/CMakeSetupDialog.h

@@ -68,6 +68,7 @@ protected:
   //{{AFX_MSG(CMakeSetupDialog)
   virtual BOOL OnInitDialog();
   afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
+  afx_msg void OnOK();
   afx_msg void OnPaint();
   afx_msg HCURSOR OnQueryDragIcon();
   afx_msg void OnBrowseWhereSource();

+ 16 - 7
Source/MFCDialog/PropertyList.cpp

@@ -143,8 +143,7 @@ int CPropertyList::AddProperty(const char* name,
         {
         pItem->m_curValue = value;
         pItem->m_HelpString = helpString;
-        m_Dirty = true;
-        Invalidate();
+        InvalidateList();
         }
       return i;
       }
@@ -350,8 +349,11 @@ void CPropertyList::OnChangeEditBox()
   m_editBox.GetWindowText(newStr);
 	
   CPropertyItem* pItem = (CPropertyItem*) GetItemDataPtr(m_curSel);
-  pItem->m_curValue = newStr;
-  m_Dirty = true;
+  if(pItem->m_curValue != newStr)
+    {
+    pItem->m_curValue = newStr;
+    m_Dirty = true;
+    }
 }
 
 void CPropertyList::OnCheckBox()
@@ -408,7 +410,7 @@ void CPropertyList::OnButton()
       cmSystemTools::ConvertToUnixSlashes(path);
       pItem->m_curValue = path.c_str();
       m_Dirty = true;
-      Invalidate();
+      InvalidateList();
       }
     }
    else if (pItem->m_nItemType == CPropertyList::PATH)
@@ -427,7 +429,7 @@ void CPropertyList::OnButton()
       cmSystemTools::ConvertToUnixSlashes(path);
       pItem->m_curValue = path.c_str();
       m_Dirty = true;
-      Invalidate();
+      InvalidateList();
       }
     }
 }
@@ -579,7 +581,7 @@ void CPropertyList::OnDelete()
   m_PropertyItems.erase(pItem);
   delete pItem;
   this->DeleteString(m_curSel);
-  Invalidate();
+  InvalidateList();
 }
 
 void CPropertyList::OnHelp()
@@ -603,5 +605,12 @@ void CPropertyList::RemoveAll()
     delete pItem;
     this->DeleteString(0);
     }
+  InvalidateList();
+}
+
+void CPropertyList::InvalidateList()
+{
   Invalidate();
+  m_Dirty = true;
 }
+

+ 5 - 1
Source/MFCDialog/PropertyList.h

@@ -55,6 +55,9 @@ public:
 
 // Operations
 public:
+  bool IsDirty() { return m_Dirty;  }
+  void ClearDirty() { m_Dirty = false;  }
+  
   int AddItem(CString txt);
   int AddProperty(const char* name,
                   const char* value,
@@ -107,7 +110,8 @@ protected:
   void InvertLine(CDC* pDC,CPoint ptFrom,CPoint ptTo);
   void DisplayButton(CRect region);
   int AddPropItem(CPropertyItem* pItem);
-
+  void InvalidateList();
+  
   CComboBox m_cmbBox;
   CEdit m_editBox;
   CButton m_btnCtrl;