diff --git a/src/web.cc b/src/web.cc index e3b5aea..2e90161 100644 --- a/src/web.cc +++ b/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,16 +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 */ - std::unique_ptr< Widget > dw_unique; - dw_unique.reset( dw ); - layout->setWidget(std::move( dw_unique )); + layout->setWidget(std::move( dw )); /* Set the page title with the bare filename (e.g. for images), * HTML pages with a