diff options
| author | Liam P. White <inkscapebrony@gmail.com> | 2014-08-07 00:40:19 +0000 |
|---|---|---|
| committer | Liam P. White <inkscapebrony@gmail.com> | 2014-08-07 00:40:19 +0000 |
| commit | 2029349f5291ae10048202732a89f34c0a179130 (patch) | |
| tree | a8bf0a1a0fb4fa8ef9777f34250e598a5b272fb3 /src/knot-ptr.cpp | |
| parent | Update to trunk r13497 (diff) | |
| download | inkscape-2029349f5291ae10048202732a89f34c0a179130.tar.gz inkscape-2029349f5291ae10048202732a89f34c0a179130.zip | |
Add in some debugging code that will complain when deleted knots are accessed by snap handler
(bzr r13341.1.120)
Diffstat (limited to 'src/knot-ptr.cpp')
| -rw-r--r-- | src/knot-ptr.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/knot-ptr.cpp b/src/knot-ptr.cpp new file mode 100644 index 000000000..de8118ba7 --- /dev/null +++ b/src/knot-ptr.cpp @@ -0,0 +1,25 @@ +#include <algorithm> +#include <glib.h> +#include <list> +#include "knot-ptr.h" + +static std::list<void*> deleted_knots; + +void knot_deleted_callback(void* knot) { + if (std::find(deleted_knots.begin(), deleted_knots.end(), knot) == deleted_knots.end()) { + deleted_knots.push_back(knot); + } +} + +void knot_created_callback(void* knot) { + std::list<void*>::iterator it = std::find(deleted_knots.begin(), deleted_knots.end(), knot); + if (it != deleted_knots.end()) { + deleted_knots.erase(it); + } +} + +void check_if_knot_deleted(void* knot) { + if (std::find(deleted_knots.begin(), deleted_knots.end(), knot) != deleted_knots.end()) { + g_warning("Accessed knot after it was freed at %p", knot); + } +} |
