[Cmake-commits] CMake branch, next, updated. v2.8.11.2-3632-g5b6bbe5
Ben Boeckel
ben.boeckel at kitware.com
Fri Aug 2 16:06:36 EDT 2013
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".
The branch, next has been updated
via 5b6bbe56ef4e9278bce012c60a9b47844a1c76bc (commit)
via 7207d8c50b0ae3c10f48526198e04fef11057f87 (commit)
via a3d9eb6daee3b2ceec2e66a61f8a3be6dcc7be74 (commit)
via 0c0be4742afd5580c6e2daf0b794844bc52a8be6 (commit)
via de119d4b39dc1eb1dc3469408f53972f8dc68d0d (commit)
via 61f73a9e5ff79823683ae9e62f312845fdd5e83a (commit)
via 330bcb81b59c73f2a6720b272277376dca6c41a3 (commit)
from e5484a43278e4a45ded976c9884311028cf06100 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=5b6bbe56ef4e9278bce012c60a9b47844a1c76bc
commit 5b6bbe56ef4e9278bce012c60a9b47844a1c76bc
Merge: e5484a4 7207d8c
Author: Ben Boeckel <ben.boeckel at kitware.com>
AuthorDate: Fri Aug 2 16:06:35 2013 -0400
Commit: CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Fri Aug 2 16:06:35 2013 -0400
Merge topic 'dev/fix-variable-watch-crash' into next
7207d8c Fix a typo in the watch command error message
a3d9eb6 Prevent making extra entries in the watch map
0c0be47 Pass off a clone of the command for the callback
de119d4 Add a field for a deleter of the client data
61f73a9 Store client data as pointers
330bcb8 Copy handlers in cmVariableWatchCommand::Clone()
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7207d8c50b0ae3c10f48526198e04fef11057f87
commit 7207d8c50b0ae3c10f48526198e04fef11057f87
Author: Ben Boeckel <mathstuf at gmail.com>
AuthorDate: Fri Aug 2 15:49:50 2013 -0400
Commit: Ben Boeckel <mathstuf at gmail.com>
CommitDate: Fri Aug 2 15:49:50 2013 -0400
Fix a typo in the watch command error message
diff --git a/Source/cmVariableWatchCommand.cxx b/Source/cmVariableWatchCommand.cxx
index 6cf02fb..38ce25b 100644
--- a/Source/cmVariableWatchCommand.cxx
+++ b/Source/cmVariableWatchCommand.cxx
@@ -115,7 +115,7 @@ void cmVariableWatchCommand::VariableAccessed(const std::string& variable,
cmOStringStream error;
error << "Error in cmake code at\n"
<< arg.FilePath << ":" << arg.Line << ":\n"
- << "A command failed during the invocation of callback\""
+ << "A command failed during the invocation of callback \""
<< command << "\".";
cmSystemTools::Error(error.str().c_str());
this->InCallback = false;
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a3d9eb6daee3b2ceec2e66a61f8a3be6dcc7be74
commit a3d9eb6daee3b2ceec2e66a61f8a3be6dcc7be74
Author: Ben Boeckel <mathstuf at gmail.com>
AuthorDate: Fri Aug 2 15:49:28 2013 -0400
Commit: Ben Boeckel <mathstuf at gmail.com>
CommitDate: Fri Aug 2 15:49:28 2013 -0400
Prevent making extra entries in the watch map
diff --git a/Source/cmVariableWatch.cxx b/Source/cmVariableWatch.cxx
index 9a199ff..db36599 100644
--- a/Source/cmVariableWatch.cxx
+++ b/Source/cmVariableWatch.cxx
@@ -78,6 +78,10 @@ void cmVariableWatch::AddWatch(const std::string& variable,
void cmVariableWatch::RemoveWatch(const std::string& variable,
WatchMethod method)
{
+ if ( !this->WatchMap.count(variable) )
+ {
+ return;
+ }
cmVariableWatch::VectorOfPairs* vp = &this->WatchMap[variable];
cmVariableWatch::VectorOfPairs::iterator it;
for ( it = vp->begin(); it != vp->end(); ++it )
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0c0be4742afd5580c6e2daf0b794844bc52a8be6
commit 0c0be4742afd5580c6e2daf0b794844bc52a8be6
Author: Ben Boeckel <mathstuf at gmail.com>
AuthorDate: Fri Aug 2 15:45:15 2013 -0400
Commit: Ben Boeckel <mathstuf at gmail.com>
CommitDate: Fri Aug 2 15:45:15 2013 -0400
Pass off a clone of the command for the callback
The command itself is owned by the cmMakefile class, but the
cmVariableWatch which holds a pointer to the cmVariableWatchCommand via
the client_data for the callback outlives the cmMakefile class in the Qt
GUI. This means that when the cmMakefile is destroyed, the variable
watch is still in effect, but with a stale pointer.
To remedy this, a clone of the command is given as the client data and
the cmVariableWatch class is given the task of deleting the memory.
An example CMakeLists.txt which demonstrates the issue (only displayed
in cmake-gui, so no tests can be written for it):
set(var 0)
variable_watch(var)
diff --git a/Source/cmVariableWatchCommand.cxx b/Source/cmVariableWatchCommand.cxx
index 297a92b..6cf02fb 100644
--- a/Source/cmVariableWatchCommand.cxx
+++ b/Source/cmVariableWatchCommand.cxx
@@ -24,6 +24,14 @@ static void cmVariableWatchCommandVariableAccessed(
}
//----------------------------------------------------------------------------
+static void deleteVariableWatchCommand(void* client_data)
+{
+ cmVariableWatchCommand* command
+ = static_cast<cmVariableWatchCommand*>(client_data);
+ delete command;
+}
+
+//----------------------------------------------------------------------------
cmVariableWatchCommand::cmVariableWatchCommand()
{
this->InCallback = false;
@@ -53,7 +61,8 @@ bool cmVariableWatchCommand
}
this->Makefile->GetCMakeInstance()->GetVariableWatch()->AddWatch(
- variable, cmVariableWatchCommandVariableAccessed, this);
+ variable, cmVariableWatchCommandVariableAccessed,
+ this->Clone(), deleteVariableWatchCommand);
return true;
}
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=de119d4b39dc1eb1dc3469408f53972f8dc68d0d
commit de119d4b39dc1eb1dc3469408f53972f8dc68d0d
Author: Ben Boeckel <mathstuf at gmail.com>
AuthorDate: Fri Aug 2 15:44:15 2013 -0400
Commit: Ben Boeckel <mathstuf at gmail.com>
CommitDate: Fri Aug 2 15:44:15 2013 -0400
Add a field for a deleter of the client data
The client data is arbitrary and the callback may be called an
unspecified number of times, so the cmVariableWatch must be the one to
delete the client data in the end.
diff --git a/Source/cmVariableWatch.cxx b/Source/cmVariableWatch.cxx
index 9b72df6..9a199ff 100644
--- a/Source/cmVariableWatch.cxx
+++ b/Source/cmVariableWatch.cxx
@@ -53,11 +53,13 @@ cmVariableWatch::~cmVariableWatch()
}
void cmVariableWatch::AddWatch(const std::string& variable,
- WatchMethod method, void* client_data /*=0*/)
+ WatchMethod method, void* client_data /*=0*/,
+ DeleteData delete_data /*=0*/)
{
cmVariableWatch::Pair* p = new cmVariableWatch::Pair;
p->Method = method;
p->ClientData = client_data;
+ p->DeleteDataCall = delete_data;
cmVariableWatch::VectorOfPairs* vp = &this->WatchMap[variable];
cmVariableWatch::VectorOfPairs::size_type cc;
for ( cc = 0; cc < vp->size(); cc ++ )
diff --git a/Source/cmVariableWatch.h b/Source/cmVariableWatch.h
index 45273e5..d666815 100644
--- a/Source/cmVariableWatch.h
+++ b/Source/cmVariableWatch.h
@@ -26,6 +26,7 @@ class cmVariableWatch
public:
typedef void (*WatchMethod)(const std::string& variable, int access_type,
void* client_data, const char* newValue, const cmMakefile* mf);
+ typedef void (*DeleteData)(void* client_data);
cmVariableWatch();
~cmVariableWatch();
@@ -34,7 +35,7 @@ public:
* Add watch to the variable
*/
void AddWatch(const std::string& variable, WatchMethod method,
- void* client_data=0);
+ void* client_data=0, DeleteData delete_data=0);
void RemoveWatch(const std::string& variable, WatchMethod method);
/**
@@ -67,7 +68,15 @@ protected:
{
WatchMethod Method;
void* ClientData;
- Pair() : Method(0), ClientData(0) {}
+ DeleteData DeleteDataCall;
+ Pair() : Method(0), ClientData(0), DeleteDataCall(0) {}
+ ~Pair()
+ {
+ if (this->DeleteDataCall && this->ClientData)
+ {
+ this->DeleteDataCall(this->ClientData);
+ }
+ }
};
typedef std::vector< Pair* > VectorOfPairs;
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=61f73a9e5ff79823683ae9e62f312845fdd5e83a
commit 61f73a9e5ff79823683ae9e62f312845fdd5e83a
Author: Ben Boeckel <mathstuf at gmail.com>
AuthorDate: Fri Aug 2 15:43:15 2013 -0400
Commit: Ben Boeckel <mathstuf at gmail.com>
CommitDate: Fri Aug 2 15:43:15 2013 -0400
Store client data as pointers
The STL containers create extra copies which makes keeping track of the
owner of the client data much messier.
diff --git a/Source/cmVariableWatch.cxx b/Source/cmVariableWatch.cxx
index 3905e9b..9b72df6 100644
--- a/Source/cmVariableWatch.cxx
+++ b/Source/cmVariableWatch.cxx
@@ -37,21 +37,35 @@ cmVariableWatch::cmVariableWatch()
cmVariableWatch::~cmVariableWatch()
{
+ cmVariableWatch::StringToVectorOfPairs::iterator svp_it;
+
+ for ( svp_it = this->WatchMap.begin();
+ svp_it != this->WatchMap.end(); ++svp_it )
+ {
+ cmVariableWatch::VectorOfPairs::iterator p_it;
+
+ for ( p_it = svp_it->second.begin();
+ p_it != svp_it->second.end(); ++p_it )
+ {
+ delete *p_it;
+ }
+ }
}
void cmVariableWatch::AddWatch(const std::string& variable,
WatchMethod method, void* client_data /*=0*/)
{
- cmVariableWatch::Pair p;
- p.Method = method;
- p.ClientData = client_data;
+ cmVariableWatch::Pair* p = new cmVariableWatch::Pair;
+ p->Method = method;
+ p->ClientData = client_data;
cmVariableWatch::VectorOfPairs* vp = &this->WatchMap[variable];
cmVariableWatch::VectorOfPairs::size_type cc;
for ( cc = 0; cc < vp->size(); cc ++ )
{
- cmVariableWatch::Pair* pair = &(*vp)[cc];
+ cmVariableWatch::Pair* pair = (*vp)[cc];
if ( pair->Method == method )
{
+ delete pair;
(*vp)[cc] = p;
return;
}
@@ -66,7 +80,7 @@ void cmVariableWatch::RemoveWatch(const std::string& variable,
cmVariableWatch::VectorOfPairs::iterator it;
for ( it = vp->begin(); it != vp->end(); ++it )
{
- if ( it->Method == method )
+ if ( (*it)->Method == method )
{
vp->erase(it);
return;
@@ -87,7 +101,7 @@ void cmVariableWatch::VariableAccessed(const std::string& variable,
cmVariableWatch::VectorOfPairs::const_iterator it;
for ( it = vp->begin(); it != vp->end(); it ++ )
{
- it->Method(variable, access_type, it->ClientData,
+ (*it)->Method(variable, access_type, (*it)->ClientData,
newValue, mf);
}
}
diff --git a/Source/cmVariableWatch.h b/Source/cmVariableWatch.h
index 7dd4ac5..45273e5 100644
--- a/Source/cmVariableWatch.h
+++ b/Source/cmVariableWatch.h
@@ -70,7 +70,7 @@ protected:
Pair() : Method(0), ClientData(0) {}
};
- typedef std::vector< Pair > VectorOfPairs;
+ typedef std::vector< Pair* > VectorOfPairs;
typedef std::map<cmStdString, VectorOfPairs > StringToVectorOfPairs;
StringToVectorOfPairs WatchMap;
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=330bcb81b59c73f2a6720b272277376dca6c41a3
commit 330bcb81b59c73f2a6720b272277376dca6c41a3
Author: Ben Boeckel <mathstuf at gmail.com>
AuthorDate: Fri Aug 2 15:41:45 2013 -0400
Commit: Ben Boeckel <mathstuf at gmail.com>
CommitDate: Fri Aug 2 15:41:45 2013 -0400
Copy handlers in cmVariableWatchCommand::Clone()
It's not really a clone if they're not copied.
diff --git a/Source/cmVariableWatchCommand.h b/Source/cmVariableWatchCommand.h
index 3abc088..0fca80f 100644
--- a/Source/cmVariableWatchCommand.h
+++ b/Source/cmVariableWatchCommand.h
@@ -33,7 +33,9 @@ public:
*/
virtual cmCommand* Clone()
{
- return new cmVariableWatchCommand;
+ cmVariableWatchCommand* cmd = new cmVariableWatchCommand;
+ cmd->Handlers = this->Handlers;
+ return cmd;
}
//! Default constructor
-----------------------------------------------------------------------
Summary of changes:
Source/cmVariableWatch.cxx | 34 +++++++++++++++++++++++++++-------
Source/cmVariableWatch.h | 15 ++++++++++++---
Source/cmVariableWatchCommand.cxx | 13 +++++++++++--
Source/cmVariableWatchCommand.h | 4 +++-
4 files changed, 53 insertions(+), 13 deletions(-)
hooks/post-receive
--
CMake
More information about the Cmake-commits
mailing list