Quantcast
Channel: SmartClient Forums
Viewing all articles
Browse latest Browse all 4756

destroy vs markForDestroy

$
0
0
I've been reviewing our use of destroy and replacing it with markForDestroy in most cases as per the Javadoc for Canvas.markForDestroy().

However, I would like clarification on a couple scenarios as we are making changes in a number of places and wish to confirm before proceeding.

1. In the example below where a Tab is being selected and populated with a new pane, is it proper to call markForDestroy() here or should we be destroying the old pane synchronously using destroy().

Code:

tab.addTabSelectedHandler(new TabSelectedHandler() {
    @Override
    public void onTabSelected(TabSelectedEvent event) {
        Canvas newCanvas = createSomeNewCanvas();
        Canvas oldCanvas = tab.getPane();
        tab.setPane(newCanvas);
        if (oldCanvas != null) oldCanvas.markForDestroy();
    }
});

2. In the example below, where destroy() is being called on object, and that object uses a context Menu that also needs to be destroyed, should we be calling destroy() or markForDestroy().

Code:

@Override
public void destroy() {
    super.destroy();
    if (ctxMenu != null) {
        ctxMenu.markForDestroy();
        ctxMenu = null;
    }
}

Thank you

Viewing all articles
Browse latest Browse all 4756

Trending Articles