From 0533bf991e946b09053753566f209940f500d368 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Tue, 16 Dec 2014 15:05:47 +0100 Subject: Debugging routines to print out XML, SP Object, and Display Item trees. (bzr r13802) --- src/sp-object.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/sp-object.cpp') diff --git a/src/sp-object.cpp b/src/sp-object.cpp index 4e45eb824..3b09d80e8 100644 --- a/src/sp-object.cpp +++ b/src/sp-object.cpp @@ -1523,6 +1523,22 @@ char* SPObject::textualContent() const return g_string_free(text, FALSE); } +// For debugging: Print SP tree structure. +void SPObject::recursivePrintTree( unsigned level ) +{ + if (level == 0) { + std::cout << "SP Object Tree" << std::endl; + } + std::cout << "SP: "; + for (unsigned i = 0; i < level; ++i) { + std::cout << " "; + } + std::cout << (getId()?getId():"No object id") << std::endl; + for (SPObject *child = children; child; child = child->next) { + child->recursivePrintTree( level+1 ); + } +} + /* Local Variables: mode:c++ -- cgit v1.2.3 From f01a18216e26fd87a53188018e03527c7fdf8a57 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Tue, 23 Dec 2014 10:25:08 +0100 Subject: Use gray for 'context-fill' and 'context-stroke' in marker selector. Fix rendering bug when elements with 'context-fill' and 'context-stroke' are inside groups. (bzr r13822) --- src/sp-object.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/sp-object.cpp') diff --git a/src/sp-object.cpp b/src/sp-object.cpp index 3b09d80e8..776b020d2 100644 --- a/src/sp-object.cpp +++ b/src/sp-object.cpp @@ -131,6 +131,7 @@ SPObject::SPObject() // polygon, text, tspan, tref, textPath, altGlyph, glyphRef, marker, linearGradient, radialGradient, // stop, pattern, clipPath, mask, filter, feImage, a, font, glyph, missing-glyph, foreignObject this->style = sp_style_new_from_object(this); + this->context_style = NULL; } SPObject::~SPObject() { -- cgit v1.2.3 From 497b9890e0cb85fced32d6958b465d40212db482 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Wed, 24 Dec 2014 10:03:50 +0100 Subject: Remove sp_style_new_from_object() (bzr r13822.1.1) --- src/sp-object.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/sp-object.cpp') diff --git a/src/sp-object.cpp b/src/sp-object.cpp index 776b020d2..b0b482cf2 100644 --- a/src/sp-object.cpp +++ b/src/sp-object.cpp @@ -130,7 +130,7 @@ SPObject::SPObject() // vg, g, defs, desc, title, symbol, use, image, switch, path, rect, circle, ellipse, line, polyline, // polygon, text, tspan, tref, textPath, altGlyph, glyphRef, marker, linearGradient, radialGradient, // stop, pattern, clipPath, mask, filter, feImage, a, font, glyph, missing-glyph, foreignObject - this->style = sp_style_new_from_object(this); + this->style = new SPStyle( NULL, this ); // Is it necessary to call with "this"? this->context_style = NULL; } -- cgit v1.2.3 From c10ae6598c095b0273672f764f0fe0e684c94b87 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Wed, 24 Dec 2014 11:27:30 +0100 Subject: Remove sp_style_read_from_object() (bzr r13822.1.3) --- src/sp-object.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/sp-object.cpp') diff --git a/src/sp-object.cpp b/src/sp-object.cpp index b0b482cf2..124471545 100644 --- a/src/sp-object.cpp +++ b/src/sp-object.cpp @@ -915,7 +915,7 @@ void SPObject::set(unsigned int key, gchar const* value) { object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG); break; case SP_ATTR_STYLE: - sp_style_read_from_object(object->style, object); + object->style->readFromObject( object ); object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG); break; default: -- cgit v1.2.3 From 9a8bd0c8c29161a2fd91ccb48a3a813d4a45ac99 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Thu, 25 Dec 2014 12:40:35 +0100 Subject: Remove sp_style_write_string() and sp_style_write_difference(). (bzr r13822.1.4) --- src/sp-object.cpp | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'src/sp-object.cpp') diff --git a/src/sp-object.cpp b/src/sp-object.cpp index 124471545..d492e7817 100644 --- a/src/sp-object.cpp +++ b/src/sp-object.cpp @@ -1007,9 +1007,8 @@ Inkscape::XML::Node* SPObject::write(Inkscape::XML::Document *doc, Inkscape::XML repr->setAttribute("inkscape:collect", NULL); } - SPStyle const *const obj_style = this->style; - if (obj_style) { - gchar *s = sp_style_write_string(obj_style, SP_STYLE_FLAG_IFSET); + if (style) { + Glib::ustring s = style->write(SP_STYLE_FLAG_IFSET); // Check for valid attributes. This may be time consuming. // It is useful, though, for debugging Inkscape code. @@ -1017,17 +1016,14 @@ Inkscape::XML::Node* SPObject::write(Inkscape::XML::Document *doc, Inkscape::XML if( prefs->getBool("/options/svgoutput/check_on_editing") ) { unsigned int flags = sp_attribute_clean_get_prefs(); - Glib::ustring s_cleaned = sp_attribute_clean_style( repr, s, flags ); - g_free( s ); - s = (s_cleaned.empty() ? NULL : g_strdup (s_cleaned.c_str())); + Glib::ustring s_cleaned = sp_attribute_clean_style( repr, s.c_str(), flags ); } - if( s == NULL || strcmp(s,"") == 0 ) { + if( s.empty() ) { repr->setAttribute("style", NULL); } else { - repr->setAttribute("style", s); + repr->setAttribute("style", s.c_str()); } - g_free(s); } else { /** \todo I'm not sure what to do in this case. Bug #1165868 -- cgit v1.2.3 From 3598d85ed64693808296324289a2d6e5284d486e Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Thu, 25 Dec 2014 17:05:40 +0100 Subject: Remove sp_style_merge_from_parent() and sp_style_merge_from_dying_parent(). (bzr r13822.1.5) --- src/sp-object.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/sp-object.cpp') diff --git a/src/sp-object.cpp b/src/sp-object.cpp index d492e7817..af8855562 100644 --- a/src/sp-object.cpp +++ b/src/sp-object.cpp @@ -1145,7 +1145,7 @@ void SPObject::updateDisplay(SPCtx *ctx, unsigned int flags) */ if ((flags & SP_OBJECT_STYLE_MODIFIED_FLAG) && (flags & SP_OBJECT_PARENT_MODIFIED_FLAG)) { if (this->style && this->parent) { - sp_style_merge_from_parent(this->style, this->parent->style); + style->cascade( this->parent->style ); } } -- cgit v1.2.3 From 05f2f043bdbadefa4ea435981e1a728420d6b93c Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Thu, 25 Dec 2014 20:30:29 +0100 Subject: Remove sp_style_new(). (bzr r13822.1.6) --- src/sp-object.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/sp-object.cpp') diff --git a/src/sp-object.cpp b/src/sp-object.cpp index af8855562..4f213f943 100644 --- a/src/sp-object.cpp +++ b/src/sp-object.cpp @@ -145,6 +145,8 @@ SPObject::~SPObject() { sp_object_unref(this->_successor, NULL); this->_successor = NULL; } + + delete this->style; } // CPPIFY: make pure virtual -- cgit v1.2.3 From c784e87f3b53e823dfb303e296ede834accc9322 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Fri, 26 Dec 2014 15:44:07 +0100 Subject: SPStyle ref counting clean up. (bzr r13822.1.7) --- src/sp-object.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'src/sp-object.cpp') diff --git a/src/sp-object.cpp b/src/sp-object.cpp index 4f213f943..059fa8093 100644 --- a/src/sp-object.cpp +++ b/src/sp-object.cpp @@ -146,7 +146,18 @@ SPObject::~SPObject() { this->_successor = NULL; } - delete this->style; + if( style == NULL ) { + // style pointer could be NULL if unreffed too many times. + // Conjecture: style pointer is never NULL. + std::cerr << "SPObject::~SPObject(): style pointer is NULL" << std::endl; + } else if( style->refCount() > 1 ) { + // Several classes ref style. + // Conjecture: style pointer should be unreffed by other classes before reaching here. + std::cerr << "SPObject::~SPObject(): someone else still holding ref to style" << std::endl; + sp_style_unref( this->style ); + } else { + delete this->style; + } } // CPPIFY: make pure virtual @@ -798,9 +809,10 @@ void SPObject::releaseReferences() { g_assert(!this->id); } - if (this->style) { - this->style = sp_style_unref(this->style); - } + // style belongs to SPObject, we should not need to unref here. + // if (this->style) { + // this->style = sp_style_unref(this->style); + // } this->document = NULL; this->repr = NULL; -- cgit v1.2.3