summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2016-03-23 16:18:08 -0400
committerBrad King <brad.king@kitware.com>2016-03-23 16:18:08 -0400
commit277b7567f747bbfd8658a395da8eba79a2e01037 (patch)
tree2bd7a5ff6b6c9ac1da97c6657766ae4cc1bc458e
parentf77ad2c736061718c870dc09255efd9dea259d0d (diff)
parentc61040282557ba268e144ffa5e2d1935b5991d8d (diff)
downloadcmake-277b7567f747bbfd8658a395da8eba79a2e01037.tar.gz
Merge branch 'fix-variable_watch-reallocation' into release
-rw-r--r--Source/cmMakefile.cxx23
-rw-r--r--Source/cmVariableWatch.cxx4
-rw-r--r--Source/cmVariableWatch.h2
3 files changed, 19 insertions, 10 deletions
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 950b247356..600c985f05 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -2531,15 +2531,22 @@ const char* cmMakefile::GetDefinition(const std::string& name) const
cmVariableWatch* vv = this->GetVariableWatch();
if ( vv && !this->SuppressWatches )
{
- if ( def )
- {
- vv->VariableAccessed(name, cmVariableWatch::VARIABLE_READ_ACCESS,
- def, this);
- }
- else
- {
+ bool const watch_function_executed =
vv->VariableAccessed(name,
- cmVariableWatch::UNKNOWN_VARIABLE_READ_ACCESS, def, this);
+ def ? cmVariableWatch::VARIABLE_READ_ACCESS
+ : cmVariableWatch::UNKNOWN_VARIABLE_READ_ACCESS,
+ def, this);
+
+ if (watch_function_executed)
+ {
+ // A callback was executed and may have caused re-allocation of the
+ // variable storage. Look it up again for now.
+ // FIXME: Refactor variable storage to avoid this problem.
+ def = this->StateSnapshot.GetDefinition(name);
+ if(!def)
+ {
+ def = this->GetState()->GetInitializedCacheValue(name);
+ }
}
}
#endif
diff --git a/Source/cmVariableWatch.cxx b/Source/cmVariableWatch.cxx
index 57dde31395..a200718595 100644
--- a/Source/cmVariableWatch.cxx
+++ b/Source/cmVariableWatch.cxx
@@ -96,7 +96,7 @@ void cmVariableWatch::RemoveWatch(const std::string& variable,
}
}
-void cmVariableWatch::VariableAccessed(const std::string& variable,
+bool cmVariableWatch::VariableAccessed(const std::string& variable,
int access_type,
const char* newValue,
const cmMakefile* mf) const
@@ -112,5 +112,7 @@ void cmVariableWatch::VariableAccessed(const std::string& variable,
(*it)->Method(variable, access_type, (*it)->ClientData,
newValue, mf);
}
+ return true;
}
+ return false;
}
diff --git a/Source/cmVariableWatch.h b/Source/cmVariableWatch.h
index 0ca4a5580e..2f082afe22 100644
--- a/Source/cmVariableWatch.h
+++ b/Source/cmVariableWatch.h
@@ -42,7 +42,7 @@ public:
/**
* This method is called when variable is accessed
*/
- void VariableAccessed(const std::string& variable, int access_type,
+ bool VariableAccessed(const std::string& variable, int access_type,
const char* newValue, const cmMakefile* mf) const;
/**