summaryrefslogtreecommitdiffstats
path: root/Source/QtDialog/QCMake.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2015-04-07 21:14:41 (GMT)
committerBrad King <brad.king@kitware.com>2015-04-07 21:15:04 (GMT)
commit3347c5e4f9fcdd36c06067d6c7cd5a985a9c5d94 (patch)
treed0372265c5b1f07f9b1a8a6cc9bedf96bed2dbcb /Source/QtDialog/QCMake.cxx
parent9410e24a4ad3a21b2c27d057798f723e88d14d45 (diff)
downloadCMake-3347c5e4f9fcdd36c06067d6c7cd5a985a9c5d94.zip
CMake-3347c5e4f9fcdd36c06067d6c7cd5a985a9c5d94.tar.gz
CMake-3347c5e4f9fcdd36c06067d6c7cd5a985a9c5d94.tar.bz2
Revert topic 'refactor-cache-api'
This topic was never tested without some follow-up commits. The GetCacheEntryValue API returns a pointer to memory freed on return. It will have to be revised along with the rest of the original topic.
Diffstat (limited to 'Source/QtDialog/QCMake.cxx')
-rw-r--r--Source/QtDialog/QCMake.cxx85
1 files changed, 38 insertions, 47 deletions
diff --git a/Source/QtDialog/QCMake.cxx b/Source/QtDialog/QCMake.cxx
index 08d53ce..996aa75 100644
--- a/Source/QtDialog/QCMake.cxx
+++ b/Source/QtDialog/QCMake.cxx
@@ -96,7 +96,7 @@ void QCMake::setBinaryDirectory(const QString& _dir)
emit this->binaryDirChanged(this->BinaryDirectory);
cmCacheManager *cachem = this->CMakeInstance->GetCacheManager();
this->setGenerator(QString());
- if(!this->CMakeInstance->LoadCache(
+ if(!this->CMakeInstance->GetCacheManager()->LoadCache(
this->BinaryDirectory.toLocal8Bit().data()))
{
QDir testDir(this->BinaryDirectory);
@@ -110,18 +110,16 @@ void QCMake::setBinaryDirectory(const QString& _dir)
QCMakePropertyList props = this->properties();
emit this->propertiesChanged(props);
- const char* homeDir = cachem->GetCacheEntryValue("CMAKE_HOME_DIRECTORY");
- if (homeDir)
+ cmCacheManager::CacheIterator itm = cachem->NewIterator();
+ if ( itm.Find("CMAKE_HOME_DIRECTORY"))
{
- setSourceDirectory(QString::fromLocal8Bit(homeDir));
+ setSourceDirectory(QString::fromLocal8Bit(itm.GetValue().c_str()));
}
- const char* gen = cachem->GetCacheEntryValue("CMAKE_GENERATOR");
- if (gen)
+ if ( itm.Find("CMAKE_GENERATOR"))
{
- const char* extraGen = cachem
- ->GetInitializedCacheValue("CMAKE_EXTRA_GENERATOR");
+ const char* extraGen = cachem->GetCacheValue("CMAKE_EXTRA_GENERATOR");
std::string curGen = cmExternalMakefileProjectGenerator::
- CreateFullGeneratorName(gen, extraGen? extraGen : "");
+ CreateFullGeneratorName(itm.GetValue(), extraGen? extraGen : "");
this->setGenerator(QString::fromLocal8Bit(curGen.c_str()));
}
}
@@ -196,35 +194,33 @@ void QCMake::setProperties(const QCMakePropertyList& newProps)
// set the value of properties
cmCacheManager *cachem = this->CMakeInstance->GetCacheManager();
- std::vector<std::string> cacheKeys = cachem->GetCacheEntryKeys();
- for(std::vector<std::string>::const_iterator it = cacheKeys.begin();
- it != cacheKeys.end(); ++it)
+ for(cmCacheManager::CacheIterator i = cachem->NewIterator();
+ !i.IsAtEnd(); i.Next())
{
- cmCacheManager::CacheEntryType t = cachem->GetCacheEntryType(*it);
- if(t == cmCacheManager::INTERNAL ||
- t == cmCacheManager::STATIC)
+
+ if(i.GetType() == cmCacheManager::INTERNAL ||
+ i.GetType() == cmCacheManager::STATIC)
{
continue;
}
QCMakeProperty prop;
- prop.Key = QString::fromLocal8Bit(it->c_str());
+ prop.Key = QString::fromLocal8Bit(i.GetName().c_str());
int idx = props.indexOf(prop);
if(idx == -1)
{
- toremove.append(QString::fromLocal8Bit(it->c_str()));
+ toremove.append(QString::fromLocal8Bit(i.GetName().c_str()));
}
else
{
prop = props[idx];
if(prop.Value.type() == QVariant::Bool)
{
- cachem->SetCacheEntryValue(*it, prop.Value.toBool() ? "ON" : "OFF");
+ i.SetValue(prop.Value.toBool() ? "ON" : "OFF");
}
else
{
- cachem->SetCacheEntryValue(*it,
- prop.Value.toString().toLocal8Bit().data());
+ i.SetValue(prop.Value.toString().toLocal8Bit().data());
}
props.removeAt(idx);
}
@@ -274,7 +270,7 @@ void QCMake::setProperties(const QCMakePropertyList& newProps)
}
}
- this->CMakeInstance->SaveCache(this->BinaryDirectory.toLocal8Bit().data());
+ cachem->SaveCache(this->BinaryDirectory.toLocal8Bit().data());
}
QCMakePropertyList QCMake::properties() const
@@ -282,47 +278,42 @@ QCMakePropertyList QCMake::properties() const
QCMakePropertyList ret;
cmCacheManager *cachem = this->CMakeInstance->GetCacheManager();
- std::vector<std::string> cacheKeys = cachem->GetCacheEntryKeys();
- for (std::vector<std::string>::const_iterator i = cacheKeys.begin();
- i != cacheKeys.end(); ++i)
+ for(cmCacheManager::CacheIterator i = cachem->NewIterator();
+ !i.IsAtEnd(); i.Next())
{
- cmCacheManager::CacheEntryType t = cachem->GetCacheEntryType(*i);
- if(t == cmCacheManager::INTERNAL ||
- t == cmCacheManager::STATIC ||
- t == cmCacheManager::UNINITIALIZED)
+
+ if(i.GetType() == cmCacheManager::INTERNAL ||
+ i.GetType() == cmCacheManager::STATIC ||
+ i.GetType() == cmCacheManager::UNINITIALIZED)
{
continue;
}
- const char* cachedValue = cachem->GetCacheEntryValue(*i);
-
QCMakeProperty prop;
- prop.Key = QString::fromLocal8Bit(i->c_str());
- prop.Help = QString::fromLocal8Bit(
- cachem->GetCacheEntryProperty(*i, "HELPSTRING"));
- prop.Value = QString::fromLocal8Bit(cachedValue);
- prop.Advanced = cachem->GetCacheEntryPropertyAsBool(*i, "ADVANCED");
- if(t == cmCacheManager::BOOL)
+ prop.Key = QString::fromLocal8Bit(i.GetName().c_str());
+ prop.Help = QString::fromLocal8Bit(i.GetProperty("HELPSTRING"));
+ prop.Value = QString::fromLocal8Bit(i.GetValue().c_str());
+ prop.Advanced = i.GetPropertyAsBool("ADVANCED");
+
+ if(i.GetType() == cmCacheManager::BOOL)
{
prop.Type = QCMakeProperty::BOOL;
- prop.Value = cmSystemTools::IsOn(cachedValue);
+ prop.Value = cmSystemTools::IsOn(i.GetValue().c_str());
}
- else if(t == cmCacheManager::PATH)
+ else if(i.GetType() == cmCacheManager::PATH)
{
prop.Type = QCMakeProperty::PATH;
}
- else if(t == cmCacheManager::FILEPATH)
+ else if(i.GetType() == cmCacheManager::FILEPATH)
{
prop.Type = QCMakeProperty::FILEPATH;
}
- else if(t == cmCacheManager::STRING)
+ else if(i.GetType() == cmCacheManager::STRING)
{
prop.Type = QCMakeProperty::STRING;
- const char* stringsProperty =
- cachem->GetCacheEntryProperty(*i, "STRINGS");
- if (stringsProperty)
+ if (i.PropertyExists("STRINGS"))
{
- prop.Strings = QString::fromLocal8Bit(stringsProperty).split(";");
+ prop.Strings = QString::fromLocal8Bit(i.GetProperty("STRINGS")).split(";");
}
}
@@ -406,9 +397,9 @@ QStringList QCMake::availableGenerators() const
void QCMake::deleteCache()
{
// delete cache
- this->CMakeInstance->DeleteCache(this->BinaryDirectory.toLocal8Bit().data());
+ this->CMakeInstance->GetCacheManager()->DeleteCache(this->BinaryDirectory.toLocal8Bit().data());
// reload to make our cache empty
- this->CMakeInstance->LoadCache(this->BinaryDirectory.toLocal8Bit().data());
+ this->CMakeInstance->GetCacheManager()->LoadCache(this->BinaryDirectory.toLocal8Bit().data());
// emit no generator and no properties
this->setGenerator(QString());
QCMakePropertyList props = this->properties();
@@ -421,7 +412,7 @@ void QCMake::reloadCache()
QCMakePropertyList props;
emit this->propertiesChanged(props);
// reload
- this->CMakeInstance->LoadCache(this->BinaryDirectory.toLocal8Bit().data());
+ this->CMakeInstance->GetCacheManager()->LoadCache(this->BinaryDirectory.toLocal8Bit().data());
// emit new cache properties
props = this->properties();
emit this->propertiesChanged(props);