diff options
| -rw-r--r-- | src/debug/logger.cpp | 1 | ||||
| -rw-r--r-- | src/debug/simple-event.h | 5 | ||||
| -rw-r--r-- | src/document-undo.cpp | 13 | ||||
| -rw-r--r-- | src/gc-anchored.cpp | 14 | ||||
| -rw-r--r-- | src/gc-finalized.cpp | 8 | ||||
| -rw-r--r-- | src/helper/action.cpp | 9 | ||||
| -rw-r--r-- | src/object/sp-object.cpp | 12 | ||||
| -rw-r--r-- | src/xml/simple-node.cpp | 35 |
8 files changed, 44 insertions, 53 deletions
diff --git a/src/debug/logger.cpp b/src/debug/logger.cpp index 2c76921ac..37b8221bf 100644 --- a/src/debug/logger.cpp +++ b/src/debug/logger.cpp @@ -10,6 +10,7 @@ * Released under GNU GPL v2+, read the file 'COPYING' for more information. */ +#include <cstring> #include <fstream> #include <memory> #include <string> diff --git a/src/debug/simple-event.h b/src/debug/simple-event.h index 96dde6893..983ff5346 100644 --- a/src/debug/simple-event.h +++ b/src/debug/simple-event.h @@ -20,7 +20,6 @@ #include <glib.h> // g_assert() #include "debug/event.h" -#include "util/share.h" namespace Inkscape { @@ -45,10 +44,6 @@ public: void generateChildEvents() const override {} protected: - // TODO: change all call sites for this method, and remove it. - void _addProperty(char const *name, Util::ptr_shared value) { - _properties.push_back(PropertyPair(name, std::move(std::make_shared<std::string>(value.pointer())))); - } void _addProperty(char const *name, std::shared_ptr<std::string>&& value) { _properties.push_back(PropertyPair(name, std::move(value))); } diff --git a/src/document-undo.cpp b/src/document-undo.cpp index d41771f06..23650dc9c 100644 --- a/src/document-undo.cpp +++ b/src/document-undo.cpp @@ -98,7 +98,6 @@ namespace { using Inkscape::Debug::Event; using Inkscape::Debug::SimpleEvent; -using Inkscape::Util::share_static_string; using Inkscape::Debug::timestamp; using Inkscape::Verb; @@ -108,18 +107,16 @@ class CommitEvent : public InteractionEvent { public: CommitEvent(SPDocument *doc, const gchar *key, const unsigned int type) - : InteractionEvent(share_static_string("commit")) + : InteractionEvent("commit") { - _addProperty(share_static_string("timestamp"), timestamp()); - gchar *serial = g_strdup_printf("%lu", doc->serial()); - _addProperty(share_static_string("document"), serial); - g_free(serial); + _addProperty("timestamp", timestamp().pointer()); + _addProperty("document", doc->serial()); Verb *verb = Verb::get(type); if (verb) { - _addProperty(share_static_string("context"), verb->get_id()); + _addProperty("context", verb->get_id()); } if (key) { - _addProperty(share_static_string("merge-key"), key); + _addProperty("merge-key", key); } } }; diff --git a/src/gc-anchored.cpp b/src/gc-anchored.cpp index 3f80bccde..517db2291 100644 --- a/src/gc-anchored.cpp +++ b/src/gc-anchored.cpp @@ -28,27 +28,27 @@ typedef Debug::SimpleEvent<Debug::Event::REFCOUNT> RefCountEvent; class BaseAnchorEvent : public RefCountEvent { public: BaseAnchorEvent(Anchored const *object, int bias, - Util::ptr_shared name) + char const *name) : RefCountEvent(name) { - _addProperty("base", Util::format("%p", Core::base(const_cast<Anchored *>(object)))); - _addProperty("pointer", Util::format("%p", object)); - _addProperty("class", Debug::demangle(typeid(*object).name())); - _addProperty("new-refcount", Util::format("%d", object->_anchored_refcount() + bias)); + _addProperty("base", Util::format("%p", Core::base(const_cast<Anchored *>(object))).pointer()); + _addProperty("pointer", Util::format("%p", object).pointer()); + _addProperty("class", Debug::demangle(typeid(*object).name()).pointer()); + _addProperty("new-refcount", object->_anchored_refcount() + bias); } }; class AnchorEvent : public BaseAnchorEvent { public: AnchorEvent(Anchored const *object) - : BaseAnchorEvent(object, 1, Util::share_static_string("gc-anchor")) + : BaseAnchorEvent(object, 1, "gc-anchor") {} }; class ReleaseEvent : public BaseAnchorEvent { public: ReleaseEvent(Anchored const *object) - : BaseAnchorEvent(object, -1, Util::share_static_string("gc-release")) + : BaseAnchorEvent(object, -1, "gc-release") {} }; diff --git a/src/gc-finalized.cpp b/src/gc-finalized.cpp index 3d4304862..8bba510d2 100644 --- a/src/gc-finalized.cpp +++ b/src/gc-finalized.cpp @@ -40,11 +40,11 @@ typedef Debug::SimpleEvent<Debug::Event::FINALIZERS> BaseEvent; class FinalizerEvent : public BaseEvent { public: FinalizerEvent(Finalized *object) - : BaseEvent(Util::share_static_string("gc-finalizer")) + : BaseEvent("gc-finalizer") { - _addProperty("base", Util::format("%p", Core::base(object))); - _addProperty("pointer", Util::format("%p", object)); - _addProperty("class", Util::share_static_string(typeid(*object).name())); + _addProperty("base", Util::format("%p", Core::base(object)).pointer()); + _addProperty("pointer", Util::format("%p", object).pointer()); + _addProperty("class", typeid(*object).name()); } }; diff --git a/src/helper/action.cpp b/src/helper/action.cpp index 81853e086..2859f6273 100644 --- a/src/helper/action.cpp +++ b/src/helper/action.cpp @@ -105,7 +105,6 @@ namespace { using Inkscape::Debug::SimpleEvent; using Inkscape::Debug::Event; -using Inkscape::Util::share_static_string; using Inkscape::Debug::timestamp; typedef SimpleEvent<Event::INTERACTION> ActionEventBase; @@ -113,14 +112,14 @@ typedef SimpleEvent<Event::INTERACTION> ActionEventBase; class ActionEvent : public ActionEventBase { public: ActionEvent(SPAction const *action) - : ActionEventBase(share_static_string("action")) + : ActionEventBase("action") { - _addProperty(share_static_string("timestamp"), timestamp()); + _addProperty("timestamp", timestamp().pointer()); SPDocument *document = action->context.getDocument(); if (document) { - _addProperty(share_static_string("document"), document->serial()); + _addProperty("document", document->serial()); } - _addProperty(share_static_string("verb"), action->id); + _addProperty("verb", action->id); } }; diff --git a/src/object/sp-object.cpp b/src/object/sp-object.cpp index 7d1ee38a3..992c19970 100644 --- a/src/object/sp-object.cpp +++ b/src/object/sp-object.cpp @@ -202,26 +202,26 @@ typedef Debug::SimpleEvent<Debug::Event::REFCOUNT> BaseRefCountEvent; class RefCountEvent : public BaseRefCountEvent { public: - RefCountEvent(SPObject *object, int bias, Util::ptr_shared name) + RefCountEvent(SPObject *object, int bias, char const *name) : BaseRefCountEvent(name) { - _addProperty("object", Util::format("%p", object)); - _addProperty("class", Debug::demangle(g_type_name(G_TYPE_FROM_INSTANCE(object)))); - _addProperty("new-refcount", Util::format("%d", G_OBJECT(object)->ref_count + bias)); + _addProperty("object", Util::format("%p", object).pointer()); + _addProperty("class", Debug::demangle(g_type_name(G_TYPE_FROM_INSTANCE(object))).pointer()); + _addProperty("new-refcount", Util::format("%d", G_OBJECT(object)->ref_count + bias).pointer()); } }; class RefEvent : public RefCountEvent { public: RefEvent(SPObject *object) - : RefCountEvent(object, 1, Util::share_static_string("sp-object-ref")) + : RefCountEvent(object, 1, "sp-object-ref") {} }; class UnrefEvent : public RefCountEvent { public: UnrefEvent(SPObject *object) - : RefCountEvent(object, -1, Util::share_static_string("sp-object-unref")) + : RefCountEvent(object, -1, "sp-object-unref") {} }; diff --git a/src/xml/simple-node.cpp b/src/xml/simple-node.cpp index db25824dc..8996bd990 100644 --- a/src/xml/simple-node.cpp +++ b/src/xml/simple-node.cpp @@ -35,7 +35,7 @@ namespace XML { namespace { -Util::ptr_shared stringify_node(Node const &node) { +std::shared_ptr<std::string> stringify_node(Node const &node) { gchar *string; switch (node.type()) { case ELEMENT_NODE: { @@ -58,16 +58,16 @@ Util::ptr_shared stringify_node(Node const &node) { default: string = g_strdup_printf("unknown(%p)", &node); } - Util::ptr_shared result=Util::share_string(string); + std::shared_ptr<std::string> result = std::make_shared<std::string>(string); g_free(string); - return result; + return std::move(result); } typedef Debug::SimpleEvent<Debug::Event::XML> DebugXML; class DebugXMLNode : public DebugXML { public: - DebugXMLNode(Node const &node, Util::ptr_shared name) + DebugXMLNode(Node const &node, char const *name) : DebugXML(name) { _addProperty("node", stringify_node(node)); @@ -77,17 +77,17 @@ public: class DebugAddChild : public DebugXMLNode { public: DebugAddChild(Node const &node, Node const &child, Node const *prev) - : DebugXMLNode(node, Util::share_static_string("add-child")) + : DebugXMLNode(node, "add-child") { _addProperty("child", stringify_node(child)); - _addProperty("position", Util::format("%d", ( prev ? prev->position() + 1 : 0 ))); + _addProperty("position", prev ? prev->position() + 1 : 0 ); } }; class DebugRemoveChild : public DebugXMLNode { public: DebugRemoveChild(Node const &node, Node const &child) - : DebugXMLNode(node, Util::share_static_string("remove-child")) + : DebugXMLNode(node, "remove-child") { _addProperty("child", stringify_node(child)); } @@ -97,7 +97,7 @@ class DebugSetChildPosition : public DebugXMLNode { public: DebugSetChildPosition(Node const &node, Node const &child, Node const *old_prev, Node const *new_prev) - : DebugXMLNode(node, Util::share_static_string("set-child-position")) + : DebugXMLNode(node, "set-child-position") { _addProperty("child", stringify_node(child)); @@ -107,7 +107,7 @@ public: --position; } - _addProperty("position", Util::format("%d", position)); + _addProperty("position", position); } }; @@ -115,16 +115,16 @@ class DebugSetContent : public DebugXMLNode { public: DebugSetContent(Node const &node, Util::ptr_shared content) - : DebugXMLNode(node, Util::share_static_string("set-content")) + : DebugXMLNode(node, "set-content") { - _addProperty("content", content); + _addProperty("content", content.pointer()); } }; class DebugClearContent : public DebugXMLNode { public: DebugClearContent(Node const &node) - : DebugXMLNode(node, Util::share_static_string("clear-content")) + : DebugXMLNode(node, "clear-content") {} }; @@ -133,19 +133,19 @@ public: DebugSetAttribute(Node const &node, GQuark name, Util::ptr_shared value) - : DebugXMLNode(node, Util::share_static_string("set-attribute")) + : DebugXMLNode(node, "set-attribute") { - _addProperty("name", Util::share_static_string(g_quark_to_string(name))); - _addProperty("value", value); + _addProperty("name", g_quark_to_string(name)); + _addProperty("value", value.pointer()); } }; class DebugClearAttribute : public DebugXMLNode { public: DebugClearAttribute(Node const &node, GQuark name) - : DebugXMLNode(node, Util::share_static_string("clear-attribute")) + : DebugXMLNode(node, "clear-attribute") { - _addProperty("name", Util::share_static_string(g_quark_to_string(name))); + _addProperty("name", g_quark_to_string(name)); } }; @@ -154,7 +154,6 @@ public: using Util::ptr_shared; using Util::share_string; using Util::share_unsafe; -using Util::share_static_string; using Util::List; using Util::MutableList; using Util::cons; |
