summaryrefslogtreecommitdiffstats
path: root/Source/cmVariableWatchCommand.h
diff options
context:
space:
mode:
authorBen Boeckel <mathstuf@gmail.com>2013-08-02 19:41:45 (GMT)
committerBrad King <brad.king@kitware.com>2013-08-08 17:31:10 (GMT)
commitf9bb20fe2bf1d9154a3244579ea84400912473b4 (patch)
tree7284afc04b2583fa0b5eaa8062498b7bd3c74bcc /Source/cmVariableWatchCommand.h
parent05dad99f5a1ee781da52df0ccc61b236087bcd2d (diff)
downloadCMake-f9bb20fe2bf1d9154a3244579ea84400912473b4.zip
CMake-f9bb20fe2bf1d9154a3244579ea84400912473b4.tar.gz
CMake-f9bb20fe2bf1d9154a3244579ea84400912473b4.tar.bz2
variable_watch: Don't share memory for callbacks
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 fix this, each callback is now a separate entity completely and doesn't rely on the command which spawned it at all. 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)
Diffstat (limited to 'Source/cmVariableWatchCommand.h')
-rw-r--r--Source/cmVariableWatchCommand.h17
1 files changed, 4 insertions, 13 deletions
diff --git a/Source/cmVariableWatchCommand.h b/Source/cmVariableWatchCommand.h
index 3abc088..545535c 100644
--- a/Source/cmVariableWatchCommand.h
+++ b/Source/cmVariableWatchCommand.h
@@ -14,13 +14,6 @@
#include "cmCommand.h"
-class cmVariableWatchCommandHandler
-{
-public:
- typedef std::vector<std::string> VectorOfCommands;
- VectorOfCommands Commands;
-};
-
/** \class cmVariableWatchCommand
* \brief Watch when the variable changes and invoke command
*
@@ -39,6 +32,9 @@ public:
//! Default constructor
cmVariableWatchCommand();
+ //! Destructor.
+ ~cmVariableWatchCommand();
+
/**
* This is called when the command is first encountered in
* the CMakeLists.txt file.
@@ -83,13 +79,8 @@ public:
cmTypeMacro(cmVariableWatchCommand, cmCommand);
- void VariableAccessed(const std::string& variable, int access_type,
- const char* newValue, const cmMakefile* mf);
-
protected:
- std::map<std::string, cmVariableWatchCommandHandler> Handlers;
-
- bool InCallback;
+ std::set<std::string> WatchedVariables;
};