Revert "This adds some resource-ownership tracking."

This reverts commit fad3dbc39a.
This commit is contained in:
2025-04-16 04:16:04 -04:00
parent d001d2609b
commit 80f980a2e1
11 changed files with 43 additions and 47 deletions

View File

@ -390,11 +390,11 @@ FltkPlatform::FltkResourceFactory::createLabelButtonResource (const char
} }
core::ui::ComplexButtonResource * core::ui::ComplexButtonResource *
FltkPlatform::FltkResourceFactory::createComplexButtonResource (std::unique_ptr< core::Widget FltkPlatform::FltkResourceFactory::createComplexButtonResource (core::Widget
> widget, *widget,
bool relief) bool relief)
{ {
return new ui::FltkComplexButtonResource (platform, std::move( widget ), relief); return new ui::FltkComplexButtonResource (platform, widget, relief);
} }
core::ui::ListResource * core::ui::ListResource *

View File

@ -104,7 +104,7 @@ private:
core::ui::LabelButtonResource *createLabelButtonResource (const char core::ui::LabelButtonResource *createLabelButtonResource (const char
*label); *label);
core::ui::ComplexButtonResource * core::ui::ComplexButtonResource *
createComplexButtonResource (std::unique_ptr< core::Widget > widget, bool relief); createComplexButtonResource (core::Widget *widget, bool relief);
core::ui::ListResource * core::ui::ListResource *
createListResource (core::ui::ListResource::SelectionMode selectionMode, createListResource (core::ui::ListResource::SelectionMode selectionMode,
int rows); int rows);

View File

@ -726,14 +726,14 @@ void FltkLabelButtonResource::setLabel (const char *label)
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
FltkComplexButtonResource::FltkComplexButtonResource (FltkPlatform *platform, FltkComplexButtonResource::FltkComplexButtonResource (FltkPlatform *platform,
std::unique_ptr< dw::core::Widget dw::core::Widget
> widget, bool relief): *widget, bool relief):
FltkSpecificResource <dw::core::ui::ComplexButtonResource> (platform) FltkSpecificResource <dw::core::ui::ComplexButtonResource> (platform)
{ {
flatView = topView = NULL; flatView = topView = NULL;
this->relief = relief; this->relief = relief;
FltkResource::init (platform); FltkResource::init (platform);
ComplexButtonResource::init (std::move( widget )); ComplexButtonResource::init (widget);
} }
FltkComplexButtonResource::~FltkComplexButtonResource () FltkComplexButtonResource::~FltkComplexButtonResource ()

View File

@ -5,8 +5,6 @@
# error Do not include this file directly, use "fltkcore.hh" instead. # error Do not include this file directly, use "fltkcore.hh" instead.
#endif #endif
#include <memory>
#include <FL/Fl_Button.H> #include <FL/Fl_Button.H>
#include <FL/Fl_Menu.H> #include <FL/Fl_Menu.H>
#include <FL/Fl_Text_Buffer.H> #include <FL/Fl_Text_Buffer.H>
@ -286,7 +284,7 @@ protected:
Fl_Widget *createNewWidget (core::Allocation *allocation); Fl_Widget *createNewWidget (core::Allocation *allocation);
public: public:
FltkComplexButtonResource (FltkPlatform *platform, std::unique_ptr< dw::core::Widget > widget, FltkComplexButtonResource (FltkPlatform *platform, dw::core::Widget *widget,
bool relief); bool relief);
~FltkComplexButtonResource (); ~FltkComplexButtonResource ();
}; };

View File

@ -327,8 +327,10 @@ Layout::~Layout ()
if (bgImage) if (bgImage)
bgImage->unref (); bgImage->unref ();
if (topLevel) { if (topLevel) {
detachWidget (topLevel.get()); detachWidget (topLevel);
topLevel.reset(); Widget *w = topLevel;
topLevel = NULL;
delete w;
} }
delete queueResizeList; delete queueResizeList;
@ -362,7 +364,7 @@ void Layout::detachWidget (Widget *widget)
it->unref (); it->unref ();
} }
void Layout::addWidget (std::unique_ptr< Widget > widget) void Layout::addWidget (Widget *widget)
{ {
if (topLevel) { if (topLevel) {
MSG_WARN("widget already set\n"); MSG_WARN("widget already set\n");
@ -372,20 +374,20 @@ void Layout::addWidget (std::unique_ptr< Widget > widget)
// The toplevel widget always establishes a stacking context. It could // The toplevel widget always establishes a stacking context. It could
// already be set in Widget::setStyle(). // already be set in Widget::setStyle().
if (widget->stackingContextMgr == NULL && IMPL_POS) { if (widget->stackingContextMgr == NULL && IMPL_POS) {
widget->stackingContextMgr = new StackingContextMgr (widget.get()); widget->stackingContextMgr = new StackingContextMgr (widget);
DBG_OBJ_ASSOC (widget.get(), widget->stackingContextMgr); DBG_OBJ_ASSOC (widget, widget->stackingContextMgr);
widget->stackingContextWidget = widget.get(); widget->stackingContextWidget = widget;
} }
topLevel = std::move( widget ); topLevel = widget;
topLevel->layout = this; widget->layout = this;
topLevel->container = NULL; widget->container = NULL;
DBG_OBJ_SET_PTR_O (topLevel.get(), "container", topLevel->container); DBG_OBJ_SET_PTR_O (widget, "container", widget->container);
queueResizeList->clear (); queueResizeList->clear ();
topLevel->notifySetAsTopLevel (); widget->notifySetAsTopLevel ();
findtextState.setWidget (topLevel.get()); findtextState.setWidget (widget);
canvasHeightGreater = false; canvasHeightGreater = false;
DBG_OBJ_SET_SYM ("canvasHeightGreater", DBG_OBJ_SET_SYM ("canvasHeightGreater",
@ -424,16 +426,18 @@ void Layout::removeWidget ()
updateCursor (); updateCursor ();
} }
void Layout::setWidget (std::unique_ptr< Widget >widget) void Layout::setWidget (Widget *widget)
{ {
DBG_OBJ_ASSOC_CHILD (widget); DBG_OBJ_ASSOC_CHILD (widget);
widgetAtPoint = NULL; widgetAtPoint = NULL;
if (topLevel) { if (topLevel) {
topLevel.reset(); Widget *w = topLevel;
topLevel = NULL;
delete w;
} }
textZone->zoneFree (); textZone->zoneFree ();
addWidget (std::move(widget)); addWidget (widget);
updateCursor (); updateCursor ();

View File

@ -158,8 +158,7 @@ private:
Platform *platform; Platform *platform;
View *view; View *view;
std::unique_ptr< Widget > topLevel; Widget *topLevel, *widgetAtPoint;
Widget *widgetAtPoint;
lout::container::typed::Vector<Widget> *queueResizeList; lout::container::typed::Vector<Widget> *queueResizeList;
/* The state, which must be projected into the view. */ /* The state, which must be projected into the view. */
@ -282,8 +281,8 @@ public:
lout::misc::ZoneAllocator *textZone; lout::misc::ZoneAllocator *textZone;
void addWidget (std::unique_ptr< Widget > widget); void addWidget (Widget *widget);
void setWidget (std::unique_ptr< Widget > widget); void setWidget (Widget *widget);
void attachView (View *view); void attachView (View *view);
void detachView (View *view); void detachView (View *view);

View File

@ -340,15 +340,15 @@ ComplexButtonResource::ComplexButtonResource ()
click_x = click_y = -1; click_x = click_y = -1;
} }
void ComplexButtonResource::init (std::unique_ptr< Widget > widget) void ComplexButtonResource::init (Widget *widget)
{ {
childWidget = widget.get(); childWidget = widget;
/* FIXME: Buttons should not need a full Layout */ /* FIXME: Buttons should not need a full Layout */
layout = new Layout (createPlatform (), false); layout = new Layout (createPlatform (), false);
setLayout (layout); setLayout (layout);
DBG_OBJ_ASSOC_CHILD (layout); DBG_OBJ_ASSOC_CHILD (layout);
layout->setWidget (std::move( widget )); layout->setWidget (widget);
layout->connect (&layoutReceiver); layout->connect (&layoutReceiver);
if (getEmbed ()) if (getEmbed ())

View File

@ -5,8 +5,6 @@
# error Do not include this file directly, use "core.hh" instead. # error Do not include this file directly, use "core.hh" instead.
#endif #endif
#include <memory>
namespace dw { namespace dw {
namespace core { namespace core {
@ -435,7 +433,7 @@ protected:
virtual int reliefXThickness () = 0; virtual int reliefXThickness () = 0;
virtual int reliefYThickness () = 0; virtual int reliefYThickness () = 0;
void init (std::unique_ptr< Widget > widget); void init (Widget *widget);
public: public:
ComplexButtonResource (); ComplexButtonResource ();
@ -584,7 +582,7 @@ class ResourceFactory: public lout::object::Object
public: public:
virtual LabelButtonResource *createLabelButtonResource (const char *label) virtual LabelButtonResource *createLabelButtonResource (const char *label)
= 0; = 0;
virtual ComplexButtonResource *createComplexButtonResource (std::unique_ptr< Widget > widget, virtual ComplexButtonResource *createComplexButtonResource (Widget *widget,
bool relief) bool relief)
= 0; = 0;
virtual ListResource *createListResource (ListResource::SelectionMode virtual ListResource *createListResource (ListResource::SelectionMode

View File

@ -214,7 +214,7 @@ void Widget::drawInterruption (View *view, Rectangle *area,
DrawingContext *context) DrawingContext *context)
{ {
Rectangle thisArea; Rectangle thisArea;
if (intersects (layout->topLevel.get(), context->getToplevelArea (), &thisArea)) if (intersects (layout->topLevel, context->getToplevelArea (), &thisArea))
draw (view, &thisArea, context); draw (view, &thisArea, context);
context->addWidgetProcessedAsInterruption (this); context->addWidgetProcessedAsInterruption (this);

View File

@ -945,8 +945,7 @@ void Html_tag_open_button(DilloHtml *html, const char *tag, int tagsize)
if (inp_type != DILLO_HTML_INPUT_UNKNOWN) { if (inp_type != DILLO_HTML_INPUT_UNKNOWN) {
/* Render the button */ /* Render the button */
std::unique_ptr< Widget > page; Widget *page;
Widget *page_p;
Embed *embed; Embed *embed;
const char *attrbuf; const char *attrbuf;
char *name, *value; char *name, *value;
@ -960,18 +959,17 @@ void Html_tag_open_button(DilloHtml *html, const char *tag, int tagsize)
/* We used to have Textblock (prefs.limit_text_width, ...) here, /* We used to have Textblock (prefs.limit_text_width, ...) here,
* but it caused 100% CPU usage. * but it caused 100% CPU usage.
*/ */
page = std::make_unique< Textblock > (false, true); page = new Textblock (false, true);
page->setStyle (html->backgroundStyle ()); page->setStyle (html->backgroundStyle ());
page_p= page.get();
ResourceFactory *factory = HT2LT(html)->getResourceFactory(); ResourceFactory *factory = HT2LT(html)->getResourceFactory();
Resource *resource = factory->createComplexButtonResource(std::move( page ), true); Resource *resource = factory->createComplexButtonResource(page, true);
embed = new Embed(resource); embed = new Embed(resource);
// a_Dw_button_set_sensitive (DW_BUTTON (button), FALSE); // a_Dw_button_set_sensitive (DW_BUTTON (button), FALSE);
HT2TB(html)->addWidget (embed, html->backgroundStyle ()); HT2TB(html)->addWidget (embed, html->backgroundStyle ());
S_TOP(html)->textblock = html->dw = page_p; S_TOP(html)->textblock = html->dw = page;
value = a_Html_get_attr_wdef(html, tag, tagsize, "value", NULL); value = a_Html_get_attr_wdef(html, tag, tagsize, "value", NULL);
name = a_Html_get_attr_wdef(html, tag, tagsize, "name", NULL); name = a_Html_get_attr_wdef(html, tag, tagsize, "name", NULL);
@ -2044,12 +2042,11 @@ static Embed *Html_input_image(DilloHtml *html, const char *tag, int tagsize)
// At this point, we know that Image->ir represents an image // At this point, we know that Image->ir represents an image
// widget. Notice that the order of the casts matters, because // widget. Notice that the order of the casts matters, because
// of multiple inheritance. // of multiple inheritance.
std::unique_ptr< dw::Image > dwi; dw::Image *dwi = (dw::Image*)(dw::core::ImgRenderer*)Image->img_rndr;
dwi.reset( reinterpret_cast< dw::Image *>( (dw::core::ImgRenderer*)Image->img_rndr ) );
dwi->setStyle (html->backgroundStyle ()); dwi->setStyle (html->backgroundStyle ());
ResourceFactory *factory = HT2LT(html)->getResourceFactory(); ResourceFactory *factory = HT2LT(html)->getResourceFactory();
ComplexButtonResource *complex_b_r = ComplexButtonResource *complex_b_r =
factory->createComplexButtonResource(std::move( dwi ), false); factory->createComplexButtonResource(dwi, false);
button = new Embed(complex_b_r); button = new Embed(complex_b_r);
HT2TB(html)->addWidget (button, html->style ()); HT2TB(html)->addWidget (button, html->style ());
} }

View File

@ -85,7 +85,7 @@ int a_Web_dispatch_by_type (const char *Type, DilloWeb *Web,
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 */
layout->setWidget(std::unique_ptr< Widget >{ dw }); layout->setWidget(dw);
/* 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 */