Some further expansion of ownership for Widget.
This commit is contained in:
25
src/web.cc
25
src/web.cc
@ -50,8 +50,6 @@ void a_Web_init(void)
|
|||||||
int a_Web_dispatch_by_type (const char *Type, DilloWeb *Web,
|
int a_Web_dispatch_by_type (const char *Type, DilloWeb *Web,
|
||||||
CA_Callback_t *Call, void **Data)
|
CA_Callback_t *Call, void **Data)
|
||||||
{
|
{
|
||||||
Widget *dw = NULL;
|
|
||||||
|
|
||||||
_MSG("a_Web_dispatch_by_type\n");
|
_MSG("a_Web_dispatch_by_type\n");
|
||||||
|
|
||||||
BrowserWindow *bw = Web->bw;
|
BrowserWindow *bw = Web->bw;
|
||||||
@ -78,16 +76,14 @@ int a_Web_dispatch_by_type (const char *Type, DilloWeb *Web,
|
|||||||
StyleEngine styleEngine (layout, Web->url, Web->url, bw->zoom);
|
StyleEngine styleEngine (layout, Web->url, Web->url, bw->zoom);
|
||||||
styleEngine.startElement ("body", Web->bw);
|
styleEngine.startElement ("body", Web->bw);
|
||||||
|
|
||||||
dw = (Widget*) viewer(Type, Web, Call, Data);
|
std::unique_ptr< Widget > dw( reinterpret_cast< Widget* >( viewer(Type, Web, Call, Data) ) );
|
||||||
if (dw == NULL)
|
if (not dw)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
dw->setStyle (styleEngine.style (Web->bw));
|
dw->setStyle (styleEngine.style (Web->bw));
|
||||||
|
|
||||||
/* This method frees the old dw if any */
|
/* This method frees the old dw if any */
|
||||||
std::unique_ptr< Widget > dw_unique;
|
layout->setWidget(std::move( dw ));
|
||||||
dw_unique.reset( dw );
|
|
||||||
layout->setWidget(std::move( dw_unique ));
|
|
||||||
|
|
||||||
/* Set the page title with the bare filename (e.g. for images),
|
/* Set the page title with the bare filename (e.g. for images),
|
||||||
* HTML pages with a <TITLE> tag will overwrite it later */
|
* HTML pages with a <TITLE> tag will overwrite it later */
|
||||||
@ -104,16 +100,19 @@ int a_Web_dispatch_by_type (const char *Type, DilloWeb *Web,
|
|||||||
/* Let the Nav module know... */
|
/* Let the Nav module know... */
|
||||||
a_Nav_expect_done(Web->bw);
|
a_Nav_expect_done(Web->bw);
|
||||||
|
|
||||||
} else {
|
return 1;
|
||||||
|
|
||||||
|
}
|
||||||
/* A non-RootUrl. At this moment we only handle image-children */
|
/* A non-RootUrl. At this moment we only handle image-children */
|
||||||
if (!dStrnAsciiCasecmp(Type, "image/", 6)) {
|
if (!dStrnAsciiCasecmp(Type, "image/", 6)) {
|
||||||
dw = (Widget*) viewer(Type, Web, Call, Data);
|
auto dw = (Widget*) viewer(Type, Web, Call, Data);
|
||||||
} else {
|
return (dw ? 1 : -1);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
MSG_HTTP("'%s' cannot be displayed as image; has media type '%s'\n",
|
MSG_HTTP("'%s' cannot be displayed as image; has media type '%s'\n",
|
||||||
URL_STR(Web->url), Type);
|
URL_STR(Web->url), Type);
|
||||||
}
|
return -1;
|
||||||
}
|
|
||||||
return (dw ? 1 : -1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user