From 23599df23196e91a832350862814ba57de7c07bd6a26f5d8f8db8af378730436 Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Mon, 3 Mar 2025 00:49:53 -0500 Subject: [PATCH] Unique pointer a member of style node. --- src/styleengine.cc | 11 +++++------ src/styleengine.hh | 3 ++- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/styleengine.cc b/src/styleengine.cc index 637e659..634016a 100644 --- a/src/styleengine.cc +++ b/src/styleengine.cc @@ -116,16 +116,15 @@ StyleEngine::~StyleEngine () { } void StyleEngine::stackPush () { - static const Node emptyNode = { + Node emptyNode = { NULL, NULL, NULL, NULL, NULL, NULL, false, false, NULL }; - stack.push_back( emptyNode ); + stack.push_back( std::move( emptyNode ) ); } void StyleEngine::stackPop () { Node *n = &stack.at (stack.size () - 1); - delete n->styleAttrProperties; delete n->styleAttrPropertiesImportant; delete n->nonCssProperties; if (n->style) @@ -199,11 +198,11 @@ void StyleEngine::setStyle (const char *styleAttr) { assert (n->styleAttrProperties == NULL); // parse style information from style="" attribute, if it exists if (styleAttr && prefs.parse_embedded_css) { - n->styleAttrProperties = new CssPropertyList (true); + n->styleAttrProperties = std::make_unique< CssPropertyList >(true); n->styleAttrPropertiesImportant = new CssPropertyList (true); CssParser::parseDeclarationBlock (baseUrl, styleAttr, strlen (styleAttr), - n->styleAttrProperties, + n->styleAttrProperties.get(), n->styleAttrPropertiesImportant); } } @@ -934,7 +933,7 @@ Style * StyleEngine::style0 (int i, BrowserWindow *bw) { attrs.resetValues (); preprocessAttrs (&attrs); - styleAttrProperties = stack.at (i).styleAttrProperties; + styleAttrProperties = stack.at (i).styleAttrProperties.get(); styleAttrPropertiesImportant = stack.at(i).styleAttrPropertiesImportant; nonCssProperties = stack.at (i).nonCssProperties; diff --git a/src/styleengine.hh b/src/styleengine.hh index 6e79f85..ee45d75 100644 --- a/src/styleengine.hh +++ b/src/styleengine.hh @@ -14,6 +14,7 @@ #define __STYLEENGINE_HH__ #include +#include class StyleEngine; @@ -34,7 +35,7 @@ class StyleEngine; class StyleEngine { private: struct Node { - CssPropertyList *styleAttrProperties; + std::unique_ptr< CssPropertyList >styleAttrProperties; CssPropertyList *styleAttrPropertiesImportant; CssPropertyList *nonCssProperties; dw::core::style::Style *style;