From 0d99c78908c5a197764fc658c151eba819c9c7ad3284d2d3abcf894594178383 Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Sat, 9 Aug 2025 18:03:43 -0400 Subject: [PATCH] HtmlInput ownership. --- src/form.cc | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/src/form.cc b/src/form.cc index 38bf61b..f7700d1 100644 --- a/src/form.cc +++ b/src/form.cc @@ -147,7 +147,7 @@ public: //BUG: for now everything is public std::optional< std::string > init_str; /* note: some overloading - for buttons, init_str is simply the value of the button; for text entries, it is the initial value */ - DilloHtmlSelect *select; + std::unique_ptr< DilloHtmlSelect > select; bool init_val; /* only meaningful for buttons */ std::string file_data; /* only meaningful for file inputs. TODO: may become a list... */ @@ -160,7 +160,6 @@ private: public: DilloHtmlInput (DilloHtmlInputType type, Embed *embed, const std::optional< std::string > &name, const std::optional< std::string > &init_str, bool init_val); - ~DilloHtmlInput (); void appendValuesTo(std::vector< std::string > &values, bool is_active_submit); void reset(); void setEnabled(bool enabled) {if (embed) embed->setEnabled(enabled); }; @@ -216,8 +215,8 @@ class DilloHtmlSelect { private: lout::misc::SimpleVector *opts; DilloHtmlSelect (); - ~DilloHtmlSelect (); public: + ~DilloHtmlSelect (); DilloHtmlOptbase *getCurrentOpt (); void addOpt (DilloHtmlOptbase *opt); void ensureSelection (); @@ -775,7 +774,7 @@ void Html_tag_close_select(DilloHtml *html) auto input = Html_get_current_input(*html); if (input) { - DilloHtmlSelect *select = input->select; + DilloHtmlSelect *select = input->select.get(); if (input->type == DILLO_HTML_INPUT_SELECT) { // option menu interface requires that something be selected */ select->ensureSelection (); @@ -1632,7 +1631,7 @@ DilloHtmlInput::DilloHtmlInput (DilloHtmlInputType type2, Embed *embed2, switch (type) { case DILLO_HTML_INPUT_SELECT: case DILLO_HTML_INPUT_SEL_LIST: - select = new DilloHtmlSelect; + select.reset( new DilloHtmlSelect ); break; default: break; @@ -1640,15 +1639,6 @@ DilloHtmlInput::DilloHtmlInput (DilloHtmlInputType type2, Embed *embed2, reset (); } -/* - * Destructor - */ -DilloHtmlInput::~DilloHtmlInput () -{ - if (select) - delete select; -} - /** * Connect to a receiver. */