summaryrefslogtreecommitdiffstats
path: root/Source/MFCDialog
diff options
context:
space:
mode:
authorKen Martin <ken.martin@kitware.com>2002-08-28 18:51:10 (GMT)
committerKen Martin <ken.martin@kitware.com>2002-08-28 18:51:10 (GMT)
commitd0be2896d7191e56818aaac48f7177b9d92a9693 (patch)
tree42c3a9c07f1ccd9fe8683051c921463e9d639dc7 /Source/MFCDialog
parent4855fe5c10841fd3641b7405522de3278732987f (diff)
downloadCMake-d0be2896d7191e56818aaac48f7177b9d92a9693.zip
CMake-d0be2896d7191e56818aaac48f7177b9d92a9693.tar.gz
CMake-d0be2896d7191e56818aaac48f7177b9d92a9693.tar.bz2
changed cache manager and registered generators to no longer be singletons
Diffstat (limited to 'Source/MFCDialog')
-rw-r--r--Source/MFCDialog/CMakeSetup.cpp2
-rw-r--r--Source/MFCDialog/CMakeSetupDialog.cpp66
-rw-r--r--Source/MFCDialog/CMakeSetupDialog.h7
-rw-r--r--Source/MFCDialog/PropertyList.cpp11
-rw-r--r--Source/MFCDialog/PropertyList.h3
5 files changed, 55 insertions, 34 deletions
diff --git a/Source/MFCDialog/CMakeSetup.cpp b/Source/MFCDialog/CMakeSetup.cpp
index 707b9c6..e958b2f 100644
--- a/Source/MFCDialog/CMakeSetup.cpp
+++ b/Source/MFCDialog/CMakeSetup.cpp
@@ -78,8 +78,6 @@ BOOL CMakeSetup::InitInstance()
// clean up globals
cmListFileCache::GetInstance()->ClearCache();
- cmMakefileGenerator::UnRegisterGenerators();
- cmCacheManager::DeleteInstance();
// Since the dialog has been closed, return FALSE so that we exit the
// application, rather than start the application's message pump.
return FALSE;
diff --git a/Source/MFCDialog/CMakeSetupDialog.cpp b/Source/MFCDialog/CMakeSetupDialog.cpp
index 9f1e20e..4ddca54 100644
--- a/Source/MFCDialog/CMakeSetupDialog.cpp
+++ b/Source/MFCDialog/CMakeSetupDialog.cpp
@@ -110,6 +110,7 @@ CMakeSetupDialog::CMakeSetupDialog(const CMakeCommandLineInfo& cmdInfo,
{
cmSystemTools::SetErrorCallback(MFCMessageCallback);
m_RegistryKey = "Software\\Kitware\\CMakeSetup\\Settings\\StartPath";
+ m_CacheEntriesList.m_CMakeSetupDialog = this;
//{{AFX_DATA_INIT(CMakeSetupDialog)
// Get the parameters from the command line info
@@ -145,6 +146,7 @@ CMakeSetupDialog::CMakeSetupDialog(const CMakeCommandLineInfo& cmdInfo,
m_oldCX = -1;
m_deltaXRemainder = 0;
+ m_CMakeInstance = 0;
}
void CMakeSetupDialog::DoDataExchange(CDataExchange* pDX)
@@ -243,9 +245,9 @@ BOOL CMakeSetupDialog::OnInitDialog()
SetIcon(m_hIcon, FALSE); // Set small icon
// Load source and build dirs from registry
this->LoadFromRegistry();
- cmake m; // force a register of generators
+ this->m_CMakeInstance = new cmake;
std::vector<std::string> names;
- cmMakefileGenerator::GetRegisteredGenerators(names);
+ this->m_CMakeInstance->GetRegisteredGenerators(names);
for(std::vector<std::string>::iterator i = names.begin();
i != names.end(); ++i)
{
@@ -558,11 +560,16 @@ void CMakeSetupDialog::RunCMake(bool generateProjectFiles)
this->UpdateData();
// always save the current gui values to disk
this->SaveCacheFromGUI();
+ // free the old cmake and create a new one here
+ if (this->m_CMakeInstance)
+ {
+ delete this->m_CMakeInstance;
+ this->m_CMakeInstance = 0;
+ }
+ this->m_CMakeInstance = new cmake;
// Make sure we are working from the cache on disk
this->LoadCacheFromDiskToGUI();
m_OKButton.EnableWindow(false);
- // create a cmake object
- cmake make;
// create the arguments for the cmake object
std::vector<std::string> args;
args.push_back((const char*)m_PathToExecutable);
@@ -577,7 +584,7 @@ void CMakeSetupDialog::RunCMake(bool generateProjectFiles)
arg += m_GeneratorChoiceString;
args.push_back(arg);
// run the generate process
- if(make.Generate(args, generateProjectFiles) != 0)
+ if(this->m_CMakeInstance->Generate(args, generateProjectFiles) != 0)
{
cmSystemTools::Error(
"Error in generation process, project files may be invalid");
@@ -643,14 +650,14 @@ void CMakeSetupDialog::OnChangeWhereBuild()
std::string cache_file = path;
cache_file += "/CMakeCache.txt";
- cmCacheManager *cache = cmCacheManager::GetInstance();
+ cmCacheManager *cachem = this->m_CMakeInstance->GetCacheManager();
if (cmSystemTools::FileExists(cache_file.c_str()) &&
- cache->LoadCache(path.c_str()) &&
- cache->GetCacheEntry("CMAKE_HOME_DIRECTORY"))
+ cachem->LoadCache(path.c_str()) &&
+ cachem->GetCacheEntry("CMAKE_HOME_DIRECTORY"))
{
path = ConvertToWindowsPath(
- cache->GetCacheEntry("CMAKE_HOME_DIRECTORY")->m_Value.c_str());
+ cachem->GetCacheEntry("CMAKE_HOME_DIRECTORY")->m_Value.c_str());
this->m_WhereSource = path.c_str();
this->m_WhereSourceControl.SetWindowText(this->m_WhereSource);
this->OnChangeWhereSource();
@@ -666,6 +673,7 @@ void CMakeSetupDialog::OnChangeWhereBuild()
// copy from the cache manager to the cache edit list box
void CMakeSetupDialog::FillCacheGUIFromCacheManager()
{
+ cmCacheManager *cachem = this->m_CMakeInstance->GetCacheManager();
size_t size = m_CacheEntriesList.GetItems().size();
bool reverseOrder = false;
// if there are already entries in the cache, then
@@ -683,7 +691,7 @@ void CMakeSetupDialog::FillCacheGUIFromCacheManager()
CPropertyItem* item = *i;
item->m_NewValue = false;
}
- for(cmCacheManager::CacheIterator i = cmCacheManager::GetInstance()->NewIterator();
+ for(cmCacheManager::CacheIterator i = cachem->NewIterator();
!i.IsAtEnd(); i.Next())
{
const char* key = i.GetName();
@@ -700,7 +708,7 @@ void CMakeSetupDialog::FillCacheGUIFromCacheManager()
if(!m_AdvancedValues)
{
- if(cmCacheManager::GetInstance()->IsAdvanced(key))
+ if(cachem->IsAdvanced(key))
{
m_CacheEntriesList.RemoveProperty(key);
continue;
@@ -758,7 +766,7 @@ void CMakeSetupDialog::FillCacheGUIFromCacheManager()
}
}
m_OKButton.EnableWindow(false);
- if(cmCacheManager::GetInstance()->GetSize() > 0 && !cmSystemTools::GetErrorOccuredFlag())
+ if(cachem->GetSize() > 0 && !cmSystemTools::GetErrorOccuredFlag())
{
bool enable = true;
items = m_CacheEntriesList.GetItems();
@@ -787,13 +795,13 @@ void CMakeSetupDialog::FillCacheGUIFromCacheManager()
// copy from the list box to the cache manager
void CMakeSetupDialog::FillCacheManagerFromCacheGUI()
{
+ cmCacheManager *cachem = this->m_CMakeInstance->GetCacheManager();
std::set<CPropertyItem*> items = m_CacheEntriesList.GetItems();
for(std::set<CPropertyItem*>::iterator i = items.begin();
i != items.end(); ++i)
{
CPropertyItem* item = *i;
- cmCacheManager::CacheEntry *entry =
- cmCacheManager::GetInstance()->GetCacheEntry(
+ cmCacheManager::CacheEntry *entry = cachem->GetCacheEntry(
(const char*)item->m_propName);
if (entry)
{
@@ -820,14 +828,15 @@ void CMakeSetupDialog::FillCacheManagerFromCacheGUI()
//! Load cache file from m_WhereBuild and display in GUI editor
void CMakeSetupDialog::LoadCacheFromDiskToGUI()
{
+ cmCacheManager *cachem = this->m_CMakeInstance->GetCacheManager();
if(m_WhereBuild != "")
{
- cmCacheManager::GetInstance()->LoadCache(m_WhereBuild);
+ cachem->LoadCache(m_WhereBuild);
this->FillCacheGUIFromCacheManager();
- if(cmCacheManager::GetInstance()->GetCacheEntry("CMAKE_GENERATOR"))
+ if(cachem->GetCacheEntry("CMAKE_GENERATOR"))
{
std::string curGen =
- cmCacheManager::GetInstance()->GetCacheEntry("CMAKE_GENERATOR")->m_Value;
+ cachem->GetCacheEntry("CMAKE_GENERATOR")->m_Value;
if(m_GeneratorChoiceString != curGen.c_str())
{
m_GeneratorChoiceString = curGen.c_str();
@@ -840,10 +849,11 @@ void CMakeSetupDialog::LoadCacheFromDiskToGUI()
//! Save GUI values to cmCacheManager and then save to disk.
void CMakeSetupDialog::SaveCacheFromGUI()
{
+ cmCacheManager *cachem = this->m_CMakeInstance->GetCacheManager();
this->FillCacheManagerFromCacheGUI();
if(m_WhereBuild != "")
{
- cmCacheManager::GetInstance()->SaveCache(m_WhereBuild);
+ cachem->SaveCache(m_WhereBuild);
}
}
@@ -958,7 +968,6 @@ void CMakeSetupDialog::OnOk()
cmSystemTools::EnableMessages();
m_CacheEntriesList.ClearDirty();
this->RunCMake(true);
- cmMakefileGenerator::UnRegisterGenerators();
if (!(::GetKeyState(VK_SHIFT) & 0x1000))
{
CDialog::OnOK();
@@ -1111,12 +1120,13 @@ void CMakeSetupDialog::OnHelpButton()
void CMakeSetupDialog::ShowAdvancedValues()
{
- for(cmCacheManager::CacheIterator i = cmCacheManager::GetInstance()->NewIterator();
+ cmCacheManager *cachem = this->m_CMakeInstance->GetCacheManager();
+ for(cmCacheManager::CacheIterator i = cachem->NewIterator();
!i.IsAtEnd(); i.Next())
{
const char* key = i.GetName();
const cmCacheManager::CacheEntry& value = i.GetEntry();
- if(!cmCacheManager::GetInstance()->IsAdvanced(key))
+ if(!cachem->IsAdvanced(key))
{
continue;
}
@@ -1175,12 +1185,14 @@ void CMakeSetupDialog::ShowAdvancedValues()
void CMakeSetupDialog::RemoveAdvancedValues()
{
- for(cmCacheManager::CacheIterator i = cmCacheManager::GetInstance()->NewIterator();
+ cmCacheManager *cachem = this->m_CMakeInstance->GetCacheManager();
+
+ for(cmCacheManager::CacheIterator i = cachem->NewIterator();
!i.IsAtEnd(); i.Next())
{
const char* key = i.GetName();
const cmCacheManager::CacheEntry& value = i.GetEntry();
- if(cmCacheManager::GetInstance()->IsAdvanced(key))
+ if(cachem->IsAdvanced(key))
{
m_CacheEntriesList.RemoveProperty(key);
}
@@ -1229,17 +1241,17 @@ void CMakeSetupDialog::ChangeDirectoriesFromFile(const char* buffer)
std::string cache_file = path;
cache_file += "/CMakeCache.txt";
- cmCacheManager *cache = cmCacheManager::GetInstance();
+ cmCacheManager *cachem = this->m_CMakeInstance->GetCacheManager();
if (cmSystemTools::FileExists(cache_file.c_str()) &&
- cache->LoadCache(path.c_str()) &&
- cache->GetCacheEntry("CMAKE_HOME_DIRECTORY"))
+ cachem->LoadCache(path.c_str()) &&
+ cachem->GetCacheEntry("CMAKE_HOME_DIRECTORY"))
{
path = ConvertToWindowsPath(path.c_str());
this->m_WhereBuild = path.c_str();
path = ConvertToWindowsPath(
- cache->GetCacheEntry("CMAKE_HOME_DIRECTORY")->m_Value.c_str());
+ cachem->GetCacheEntry("CMAKE_HOME_DIRECTORY")->m_Value.c_str());
this->m_WhereSource = path.c_str();
}
else
diff --git a/Source/MFCDialog/CMakeSetupDialog.h b/Source/MFCDialog/CMakeSetupDialog.h
index d0c5ac1..21ff68d 100644
--- a/Source/MFCDialog/CMakeSetupDialog.h
+++ b/Source/MFCDialog/CMakeSetupDialog.h
@@ -30,6 +30,7 @@
// CMakeSetupDialog dialog
class CMakeCommandLineInfo;
+class cmake;
class CMakeSetupDialog : public CDialog
{
@@ -37,6 +38,9 @@ class CMakeSetupDialog : public CDialog
public:
CMakeSetupDialog(const CMakeCommandLineInfo& cmdInfo,
CWnd* pParent = NULL);
+ // return the cmake that is currently being used
+ cmake *GetCMakeInstance() {
+ return m_CMakeInstance; }
protected:
//! Load cache file from m_WhereBuild and display in GUI editor
void LoadCacheFromDiskToGUI();
@@ -119,8 +123,9 @@ protected:
DECLARE_MESSAGE_MAP()
int m_oldCX;
- int m_oldCY;
+ int m_oldCY;
float m_deltaXRemainder;
+ cmake *m_CMakeInstance;
};
//{{AFX_INSERT_LOCATION}}
diff --git a/Source/MFCDialog/PropertyList.cpp b/Source/MFCDialog/PropertyList.cpp
index 4887fa4..1ef3950 100644
--- a/Source/MFCDialog/PropertyList.cpp
+++ b/Source/MFCDialog/PropertyList.cpp
@@ -2,11 +2,13 @@
//
#include "stdafx.h"
-#include "PropertyList.h"
+#include "shellapi.h"
+#include "CMakeSetup.h"
+#include "CMakeSetupDialog.h"
#include "PathDialog.h"
#include "../cmCacheManager.h"
#include "../cmSystemTools.h"
-
+#include "../cmake.h"
#define IDC_PROPCMBBOX 712
#define IDC_PROPEDITBOX 713
#define IDC_PROPBTNCTRL 714
@@ -655,7 +657,7 @@ void CPropertyList::OnDelete()
return;
}
CPropertyItem* pItem = (CPropertyItem*) GetItemDataPtr(m_curSel);
- cmCacheManager::GetInstance()->RemoveCacheEntry(pItem->m_propName);
+ m_CMakeSetupDialog->GetCMakeInstance()->GetCacheManager()->RemoveCacheEntry(pItem->m_propName);
m_PropertyItems.erase(pItem);
delete pItem;
this->DeleteString(m_curSel);
@@ -680,7 +682,8 @@ void CPropertyList::RemoveAll()
for(int i =0; i < c; ++i)
{
CPropertyItem* pItem = (CPropertyItem*) GetItemDataPtr(0);
- cmCacheManager::GetInstance()->RemoveCacheEntry(pItem->m_propName);
+ m_CMakeSetupDialog->GetCMakeInstance()->GetCacheManager()
+ ->RemoveCacheEntry(pItem->m_propName);
m_PropertyItems.erase(pItem);
delete pItem;
this->DeleteString(0);
diff --git a/Source/MFCDialog/PropertyList.h b/Source/MFCDialog/PropertyList.h
index 5cda18c..535f0d0 100644
--- a/Source/MFCDialog/PropertyList.h
+++ b/Source/MFCDialog/PropertyList.h
@@ -20,6 +20,7 @@
#include "../cmStandardIncludes.h"
+class CMakeSetupDialog;
/////////////////////////////////////////////////////////////////////////////
//CPropertyList Items
@@ -34,6 +35,7 @@ public:
CString m_cmbItems;
bool m_NewValue;
bool m_Removed;
+
public:
CPropertyItem(CString propName, CString curValue,
CString helpString,
@@ -70,6 +72,7 @@ public:
// Attributes
public:
+ CMakeSetupDialog *m_CMakeSetupDialog;
// Operations
public: