From fae3e6149995446aad42fd78b4c69a9e34027aae Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Wed, 23 Jan 2019 04:57:42 +0100 Subject: Event: Make property value char const* too. --- src/debug/event.h | 10 ++++++---- src/debug/logger.cpp | 6 +++--- src/debug/simple-event.h | 12 +++++++++--- 3 files changed, 18 insertions(+), 10 deletions(-) (limited to 'src/debug') diff --git a/src/debug/event.h b/src/debug/event.h index de5cddd07..ff049d71c 100644 --- a/src/debug/event.h +++ b/src/debug/event.h @@ -13,6 +13,8 @@ #ifndef SEEN_INKSCAPE_DEBUG_EVENT_H #define SEEN_INKSCAPE_DEBUG_EVENT_H +#include +#include #include #include "util/share.h" @@ -41,14 +43,14 @@ public: struct PropertyPair { public: PropertyPair() = default; - PropertyPair(char const *n, Util::ptr_shared v) - : name(n), value(v) {} + PropertyPair(char const *n, std::shared_ptr&& v) + : name(n), value(std::move(v)) {} PropertyPair(char const *n, char const *v) : name(n), - value(Util::share_string(v)) {} + value(std::move(std::make_shared(v))) {} char const *name; - Util::ptr_shared value; + std::shared_ptr value; }; static Category category() { return OTHER; } diff --git a/src/debug/logger.cpp b/src/debug/logger.cpp index 13d79daa2..7c0990c2c 100644 --- a/src/debug/logger.cpp +++ b/src/debug/logger.cpp @@ -27,7 +27,7 @@ bool Logger::_category_mask[Event::N_CATEGORIES]; namespace { -static void write_escaped_value(std::ostream &os, Util::ptr_shared value) { +static void write_escaped_value(std::ostream &os, char const *value) { for ( char const *current=value ; *current ; ++current ) { switch (*current) { case '&': @@ -133,7 +133,7 @@ typedef SimpleEvent CoreEvent; class SessionEvent : public CoreEvent { public: - SessionEvent() : CoreEvent(Util::share_static_string("session")) { + SessionEvent() : CoreEvent("session") { _addProperty("inkscape-version", Inkscape::version_string); } }; @@ -173,7 +173,7 @@ void Logger::_start(Event const &event) { for ( unsigned i = 0 ; i < property_count ; i++ ) { Event::PropertyPair property=event.property(i); log_stream << " " << property.name << "=\""; - write_escaped_value(log_stream, property.value); + write_escaped_value(log_stream, property.value->c_str()); log_stream << "\""; } diff --git a/src/debug/simple-event.h b/src/debug/simple-event.h index 70bef77e9..1b6dc172c 100644 --- a/src/debug/simple-event.h +++ b/src/debug/simple-event.h @@ -14,6 +14,8 @@ #define SEEN_INKSCAPE_DEBUG_SIMPLE_EVENT_H #include +#include +#include #include #include // g_assert() @@ -43,11 +45,15 @@ 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, value)); + _properties.push_back(PropertyPair(name, std::move(std::make_shared(value.pointer())))); + } + void _addProperty(char const *name, std::shared_ptr&& value) { + _properties.push_back(PropertyPair(name, std::move(value))); } void _addProperty(char const *name, char const *value) { - _addProperty(name, Util::share_string(value)); + _addProperty(name, std::move(std::make_shared(value))); } void _addProperty(char const *name, long value) { _addFormattedProperty(name, "%ld", value); @@ -55,7 +61,7 @@ protected: private: char const *_name; - std::vector > _properties; + std::vector _properties; void _addFormattedProperty(char const *name, char const *format, ...) { -- cgit v1.2.3