Project

General

Profile

Actions

Bug #3807

closed

[wt-git] WItemDelegate causes memory leak?

Added by Anonymous almost 10 years ago. Updated over 9 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Benoit Daccache
Target version:
Start date:
02/19/2015
Due date:
% Done:

0%

Estimated time:

Description

Hi,

I specialised the WItemDelegate class and I saw that the editor widget is never destructed. The default implementation of doCloseEditor is:

void WItemDelegate::doCloseEditor(WWidget *editor, bool save) const
{
  closeEditor().emit(editor, save);
}

When the editor has to be destructed? I suppose after emitting the closeEditor signal, i.e., :

void WItemDelegate::doCloseEditor(WWidget *editor, bool save) const
{
  closeEditor().emit(editor, save);
  delete editor;
}

Best regards,

Stoycho


Files

Main.cpp (3.27 KB) Main.cpp memory leak when delegate is set for column > 0 Стойчо Стефанов Stoycho Stefanov, 03/24/2015 05:41 PM
Actions #1

Updated by Koen Deforche almost 10 years ago

  • Status changed from New to Rejected
  • Assignee set to Koen Deforche

Hey,

The 'editor' widget is in fact simply the widget rendered by the item delegate for a particular cell: it's treated in the same way as a normal view widget, and thus the tableview or treeview will delete it.

Regards,

koen

Actions #2

Updated by Стойчо Стефанов Stoycho Stefanov almost 10 years ago

Hey Koen,

let us consider the following scenario, where you're editing the same cell for example 10 times consecutively. Than you have created 10 editor widgets for the same cell, because every time you're editing createEditor is called and a new editor widget is instantiated. I think it's wrong to create every time a new editor when editing, not reuse it and destroy them with the parent view widget. With other words, after doCloseEditor is called the editor widget still exists despite it's never accessed again and still be there until the view widget is destructed. I thing it's much better to delete the editor before exiting doCloseEditor, OR reuse it and create it only once by the first call of createEditor.

Regards,

Stoycho

Actions #3

Updated by Koen Deforche almost 10 years ago

  • Status changed from Rejected to Feedback

In the scenario you describe, each time you code the editor it will be destroyed because the editor is later replaced by a view. So in no situation will there exist more than one widget for a particular cell at the same time. The fact that we do not reuse a previous editor has to do with flexibility, as that would impose that a single cell should always have the same editor widget.

Actions #4

Updated by Стойчо Стефанов Stoycho Stefanov almost 10 years ago

Ok, perhaps I have a bug in my delegate specialisation. But If I do not delete the editor explicitly in doCloseEditor, editor widgets are never destroyed, neither by replacing with a view nor by the tree view destructor. I'll let you know whether I can reproduce it in a test case application. Unfortunately, I do not have currently time for this.

Regards,

Stoycho

Actions #5

Updated by Koen Deforche almost 10 years ago

Yes, I would be interested in such a test case as we cannot reproduce this with the standard item delegate or a custom one (like ComboBoxDelegate)

Actions #6

Updated by Стойчо Стефанов Stoycho Stefanov over 9 years ago

Hey,

I got it. Here is the test case for wt-git revision 1084.

The editor widget is destroyed when editing within column 0, bit not within column 1, of a tree view.

regards,

Stoycho

Actions #7

Updated by Koen Deforche over 9 years ago

  • Status changed from Feedback to InProgress
  • Assignee changed from Koen Deforche to Benoit Daccache
  • Target version set to 3.3.4
Actions #8

Updated by Benoit Daccache over 9 years ago

  • Status changed from InProgress to Resolved
Actions #9

Updated by Koen Deforche over 9 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF