diff --git a/dw/fltkplatform.cc b/dw/fltkplatform.cc index 699c9e5..d532c7d 100644 --- a/dw/fltkplatform.cc +++ b/dw/fltkplatform.cc @@ -390,8 +390,7 @@ FltkPlatform::FltkResourceFactory::createLabelButtonResource (const char } core::ui::ComplexButtonResource * -FltkPlatform::FltkResourceFactory::createComplexButtonResource (std::unique_ptr< core::Widget - > widget, +FltkPlatform::FltkResourceFactory::createComplexButtonResource (std::unique_ptr< core::Widget > widget, bool relief) { return new ui::FltkComplexButtonResource (platform, std::move( widget ), relief); diff --git a/dw/fltkui.cc b/dw/fltkui.cc index fb4f839..2b987e5 100644 --- a/dw/fltkui.cc +++ b/dw/fltkui.cc @@ -726,8 +726,8 @@ void FltkLabelButtonResource::setLabel (const char *label) // ---------------------------------------------------------------------- FltkComplexButtonResource::FltkComplexButtonResource (FltkPlatform *platform, - std::unique_ptr< dw::core::Widget - > widget, bool relief): + std::unique_ptr< dw::core::Widget > widget, + bool relief): FltkSpecificResource (platform) { flatView = topView = NULL; diff --git a/dw/fltkui.hh b/dw/fltkui.hh index 1337dcf..df8613d 100644 --- a/dw/fltkui.hh +++ b/dw/fltkui.hh @@ -5,8 +5,6 @@ # error Do not include this file directly, use "fltkcore.hh" instead. #endif -#include - #include #include #include diff --git a/dw/layout.cc b/dw/layout.cc index 6ba4e7c..3337bab 100644 --- a/dw/layout.cc +++ b/dw/layout.cc @@ -377,15 +377,16 @@ void Layout::addWidget (std::unique_ptr< Widget > widget) widget->stackingContextWidget = widget.get(); } + Widget *widget_p= widget.get(); topLevel = std::move( widget ); - topLevel->layout = this; - topLevel->container = NULL; - DBG_OBJ_SET_PTR_O (topLevel.get(), "container", topLevel->container); + widget_p->layout = this; + widget_p->container = NULL; + DBG_OBJ_SET_PTR_O (widget_p, "container", widget_p->container); queueResizeList->clear (); - topLevel->notifySetAsTopLevel (); + widget_p->notifySetAsTopLevel (); - findtextState.setWidget (topLevel.get()); + findtextState.setWidget (widget_p); canvasHeightGreater = false; DBG_OBJ_SET_SYM ("canvasHeightGreater", @@ -424,16 +425,16 @@ void Layout::removeWidget () updateCursor (); } -void Layout::setWidget (std::unique_ptr< Widget >widget) +void Layout::setWidget (std::unique_ptr< Widget > widget) { - DBG_OBJ_ASSOC_CHILD (widget); + DBG_OBJ_ASSOC_CHILD (widget.get()); widgetAtPoint = NULL; if (topLevel) { topLevel.reset(); } textZone->zoneFree (); - addWidget (std::move(widget)); + addWidget (std::move( widget )); updateCursor (); diff --git a/dw/ui.hh b/dw/ui.hh index ef73241..09856d8 100644 --- a/dw/ui.hh +++ b/dw/ui.hh @@ -5,8 +5,6 @@ # error Do not include this file directly, use "core.hh" instead. #endif -#include - namespace dw { namespace core { diff --git a/src/form.cc b/src/form.cc index 5e7e7bd..13e2b0b 100644 --- a/src/form.cc +++ b/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 ()); } diff --git a/src/web.cc b/src/web.cc index 794c2f9..8dd1e46 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,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 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; }