summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Source/cmVariableWatch.cxx11
-rw-r--r--Source/cmVariableWatch.h2
2 files changed, 7 insertions, 6 deletions
diff --git a/Source/cmVariableWatch.cxx b/Source/cmVariableWatch.cxx
index 21acd3b..c2a899d 100644
--- a/Source/cmVariableWatch.cxx
+++ b/Source/cmVariableWatch.cxx
@@ -52,7 +52,7 @@ cmVariableWatch::~cmVariableWatch()
}
}
-void cmVariableWatch::AddWatch(const std::string& variable,
+bool cmVariableWatch::AddWatch(const std::string& variable,
WatchMethod method, void* client_data /*=0*/,
DeleteData delete_data /*=0*/)
{
@@ -65,14 +65,15 @@ void cmVariableWatch::AddWatch(const std::string& variable,
for ( cc = 0; cc < vp->size(); cc ++ )
{
cmVariableWatch::Pair* pair = (*vp)[cc];
- if ( pair->Method == method )
+ if ( pair->Method == method &&
+ client_data && client_data == pair->ClientData)
{
- delete pair;
- (*vp)[cc] = p;
- return;
+ // Callback already exists
+ return false;
}
}
vp->push_back(p);
+ return true;
}
void cmVariableWatch::RemoveWatch(const std::string& variable,
diff --git a/Source/cmVariableWatch.h b/Source/cmVariableWatch.h
index d666815..3b6cafd 100644
--- a/Source/cmVariableWatch.h
+++ b/Source/cmVariableWatch.h
@@ -34,7 +34,7 @@ public:
/**
* Add watch to the variable
*/
- void AddWatch(const std::string& variable, WatchMethod method,
+ bool AddWatch(const std::string& variable, WatchMethod method,
void* client_data=0, DeleteData delete_data=0);
void RemoveWatch(const std::string& variable, WatchMethod method);