Merge branch 'fix-ui-crash-bug' into master
* fix-ui-crash-bug: Ownership of page Widget plumbed to top. Plumb Widget ownership up higher. Push Widget ownership up one more level. Do the whitespace format. Some further expansion of ownership for `Widget`. Widen the unique pointer a bit more. I plumbed out ownership a bit and it hasn't crashed yet. Started plumbing out the ownership from layout. Revert "This adds some resource-ownership tracking."
This commit is contained in:
13
src/form.cc
13
src/form.cc
@ -945,8 +945,6 @@ void Html_tag_open_button(DilloHtml *html, const char *tag, int tagsize)
|
||||
|
||||
if (inp_type != DILLO_HTML_INPUT_UNKNOWN) {
|
||||
/* Render the button */
|
||||
std::unique_ptr< Widget > page;
|
||||
Widget *page_p;
|
||||
Embed *embed;
|
||||
const char *attrbuf;
|
||||
char *name, *value;
|
||||
@ -960,9 +958,9 @@ 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 = std::make_unique< Textblock > (false, true);
|
||||
std::unique_ptr< Widget > page = std::make_unique< Textblock >( false, true );
|
||||
Widget *page_p= page.get();
|
||||
page->setStyle (html->backgroundStyle ());
|
||||
page_p= page.get();
|
||||
|
||||
ResourceFactory *factory = HT2LT(html)->getResourceFactory();
|
||||
Resource *resource = factory->createComplexButtonResource(std::move( page ), true);
|
||||
@ -2044,12 +2042,13 @@ 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.
|
||||
std::unique_ptr< dw::Image > dwi;
|
||||
dwi.reset( reinterpret_cast< dw::Image *>( (dw::core::ImgRenderer*)Image->img_rndr ) );
|
||||
dw::Image *dwi = (dw::Image*)(dw::core::ImgRenderer*)Image->img_rndr;
|
||||
std::unique_ptr< dw::core::Widget > dwi_unique;
|
||||
dwi_unique.reset( dwi );
|
||||
dwi->setStyle (html->backgroundStyle ());
|
||||
ResourceFactory *factory = HT2LT(html)->getResourceFactory();
|
||||
ComplexButtonResource *complex_b_r =
|
||||
factory->createComplexButtonResource(std::move( dwi ), false);
|
||||
factory->createComplexButtonResource(std::move( dwi_unique ), false);
|
||||
button = new Embed(complex_b_r);
|
||||
HT2TB(html)->addWidget (button, html->style ());
|
||||
}
|
||||
|
||||
29
src/web.cc
29
src/web.cc
@ -50,8 +50,6 @@ void a_Web_init(void)
|
||||
int a_Web_dispatch_by_type (const char *Type, DilloWeb *Web,
|
||||
CA_Callback_t *Call, void **Data)
|
||||
{
|
||||
Widget *dw = NULL;
|
||||
|
||||
_MSG("a_Web_dispatch_by_type\n");
|
||||
|
||||
BrowserWindow *bw = Web->bw;
|
||||
@ -78,14 +76,14 @@ int a_Web_dispatch_by_type (const char *Type, DilloWeb *Web,
|
||||
StyleEngine styleEngine (layout, Web->url, Web->url, bw->zoom);
|
||||
styleEngine.startElement ("body", Web->bw);
|
||||
|
||||
dw = (Widget*) viewer(Type, Web, Call, Data);
|
||||
if (dw == NULL)
|
||||
std::unique_ptr< Widget > dw( reinterpret_cast< Widget* >( viewer(Type, Web, Call, Data) ) );
|
||||
if (not dw)
|
||||
return -1;
|
||||
|
||||
dw->setStyle (styleEngine.style (Web->bw));
|
||||
|
||||
/* This method frees the old dw if any */
|
||||
layout->setWidget(std::unique_ptr< Widget >{ dw });
|
||||
layout->setWidget(std::move( dw ));
|
||||
|
||||
/* Set the page title with the bare filename (e.g. for images),
|
||||
* HTML pages with a <TITLE> tag will overwrite it later */
|
||||
@ -102,16 +100,19 @@ int a_Web_dispatch_by_type (const char *Type, DilloWeb *Web,
|
||||
/* Let the Nav module know... */
|
||||
a_Nav_expect_done(Web->bw);
|
||||
|
||||
} else {
|
||||
/* A non-RootUrl. At this moment we only handle image-children */
|
||||
if (!dStrnAsciiCasecmp(Type, "image/", 6)) {
|
||||
dw = (Widget*) viewer(Type, Web, Call, Data);
|
||||
} else {
|
||||
MSG_HTTP("'%s' cannot be displayed as image; has media type '%s'\n",
|
||||
URL_STR(Web->url), Type);
|
||||
}
|
||||
return 1;
|
||||
|
||||
}
|
||||
return (dw ? 1 : -1);
|
||||
|
||||
/* A non-RootUrl. At this moment we only handle image-children */
|
||||
if (!dStrnAsciiCasecmp(Type, "image/", 6)) {
|
||||
auto dw = (Widget*) viewer(Type, Web, Call, Data);
|
||||
return (dw ? 1 : -1);
|
||||
}
|
||||
|
||||
MSG_HTTP("'%s' cannot be displayed as image; has media type '%s'\n",
|
||||
URL_STR(Web->url), Type);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user