Thanks for quick answer, Koen.
I just didn't dig into ~WWidgetItem::~WWidgetItem().
It seemed obvious for me, that deleting widget item should delete its underlying object...

No problem with this piece of code.
I just found this when I was working on different issue.

Snippet of code:

    m_layout = new Wt::WGridLayout();
    m_layout->addWidget(m_header, 0, 0, 1, 2);
    m_layout->addWidget(m_navigator, 1, 0);
    m_layout->addWidget(m_content, 1, 1);
    m_layout->addWidget(m_footer, 2, 0, 1, 2);

    m_layout->setRowStretch(1, 1);                                                                                                                                                                    &nb sp;             
    m_layout->setColumnStretch(1, 1);
    m_layout->setContentsMargins(0, 0, 0, 0);

    m_gui = new Wt::WContainerWidget();
    m_gui->setLayout(m_layout);
    root()->addWidget(m_gui);

Then later, on some event, I replace m_content in m_layout with new one like this:

    m_layout->removeWidget(m_content);
    m_content = new Content();
    m_layout->addWidget(m_content, 1, 1);

Everything works, but on browser refresh(!!!)  I've got _javascript_ error (Wt internal error: el has no properties bla-bla-bla).

It appeared that problem solves when I do it this way:

    m_gui->removeWidget(m_content);
    m_content = new Content();
    m_layout->addWidget(m_content, 1, 1);

IMHO, such behavior is not so obvious from the POV of the library user.

Hey Andrii,

2009/4/16  <[email protected]>:
  
Comments for method:

  /*! \brief Remove the given <i>widget</i> from the layout.
   *
   * This method finds the corresponding WWidgetItem and calls
   * removeItem(WLayoutItem *). The widget itself is not destroyed.
   *
   * \sa addWidget(WWidget *), removeItem(WLayoutItem *)
   */
  void removeWidget(WWidget *widget);

But implementation is different.

void WLayout::removeWidget(WWidget *w)
{
  WWidgetItem *widgetItem = findWidgetItem(w);

  if (widgetItem) {
    widgetItem->parentLayout()->removeItem(widgetItem);
    delete widgetItem;
  }
}
    

Not really, WWidgetItem::~WWidgetItem() does not delete the widget
itself. So the implementation and documentation are consistent. Are
you observing problems ?

Regards,
koen

------------------------------------------------------------------------------
Stay on top of everything new and different, both inside and 
around Java (TM) technology - register by April 22, and save
$200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco.
300 plus technical and hands-on sessions. Register today. 
Use priority code J9JMT32. http://p.sf.net/sfu/p
_______________________________________________
witty-interest mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/witty-interest


  

-- 
Andrii Arsirii
Streamco
http://streamco.org.ua
------------------------------------------------------------------------------
Stay on top of everything new and different, both inside and 
around Java (TM) technology - register by April 22, and save
$200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco.
300 plus technical and hands-on sessions. Register today. 
Use priority code J9JMT32. http://p.sf.net/sfu/p
_______________________________________________
witty-interest mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/witty-interest

Reply via email to