This adds some resource-ownership tracking.
Time to start spreading this out, more.
This commit is contained in:
15
src/form.cc
15
src/form.cc
@ -932,7 +932,8 @@ void Html_tag_open_button(DilloHtml *html, const char *tag, int tagsize)
|
||||
|
||||
if (inp_type != DILLO_HTML_INPUT_UNKNOWN) {
|
||||
/* Render the button */
|
||||
Widget *page;
|
||||
std::unique_ptr< Widget > page;
|
||||
Widget *page_p;
|
||||
Embed *embed;
|
||||
const char *attrbuf;
|
||||
char *name, *value;
|
||||
@ -946,17 +947,18 @@ void Html_tag_open_button(DilloHtml *html, const char *tag, int tagsize)
|
||||
/* We used to have Textblock (prefs.limit_text_width, ...) here,
|
||||
* but it caused 100% CPU usage.
|
||||
*/
|
||||
page = new Textblock (false, true);
|
||||
page = std::make_unique< Textblock > (false, true);
|
||||
page->setStyle (html->backgroundStyle ());
|
||||
page_p= page.get();
|
||||
|
||||
ResourceFactory *factory = HT2LT(html)->getResourceFactory();
|
||||
Resource *resource = factory->createComplexButtonResource(page, true);
|
||||
Resource *resource = factory->createComplexButtonResource(std::move( page ), true);
|
||||
embed = new Embed(resource);
|
||||
// a_Dw_button_set_sensitive (DW_BUTTON (button), FALSE);
|
||||
|
||||
HT2TB(html)->addWidget (embed, html->backgroundStyle ());
|
||||
|
||||
S_TOP(html)->textblock = html->dw = page;
|
||||
S_TOP(html)->textblock = html->dw = page_p;
|
||||
|
||||
value = a_Html_get_attr_wdef(html, tag, tagsize, "value", NULL);
|
||||
name = a_Html_get_attr_wdef(html, tag, tagsize, "name", NULL);
|
||||
@ -2036,11 +2038,12 @@ static Embed *Html_input_image(DilloHtml *html, const char *tag, int tagsize)
|
||||
// At this point, we know that Image->ir represents an image
|
||||
// widget. Notice that the order of the casts matters, because
|
||||
// of multiple inheritance.
|
||||
dw::Image *dwi = (dw::Image*)(dw::core::ImgRenderer*)Image->img_rndr;
|
||||
std::unique_ptr< dw::Image > dwi;
|
||||
dwi.reset( reinterpret_cast< dw::Image *>( (dw::core::ImgRenderer*)Image->img_rndr ) );
|
||||
dwi->setStyle (html->backgroundStyle ());
|
||||
ResourceFactory *factory = HT2LT(html)->getResourceFactory();
|
||||
ComplexButtonResource *complex_b_r =
|
||||
factory->createComplexButtonResource(dwi, false);
|
||||
factory->createComplexButtonResource(std::move( dwi ), false);
|
||||
button = new Embed(complex_b_r);
|
||||
HT2TB(html)->addWidget (button, html->style ());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user