Thursday, June 30, 2011

Re: Activities does not get de-registered..

On Thursday, June 30, 2011 2:06:22 PM UTC+2, El bassistos wrote:
I am doing a small "test" application and I am using Activities and
Place but can't make it work as I expect..

I have 2 Views, Activities and Places. DefaultView calls Example1View
and Vice Versa ..

In the Example1Activity I override mayStop() so that it returns a
String asking if user wants to "go to Default". It works the first
time - when I hit "go to Default", it ask if I am "sure, and then I
press " 'OK'  - that works, it swaps out the Example1View/Activity and
swap in the DefaultView/Activity.

But when I hit the "go to Example1" from the DefaultView/Activity, it
ALSO ask the question. I can see in the Debugger that first the
DefaultActivity is called, and that it behaves as expected (the
mayStop() returns null), but the ExampleView's mayStop() method is
ALSO called?? Even though it is no "in focus" - "it is about to come
in Focus" .. So it seems as the previous Example1Activity is NOT
deregistered on the EventBus, after I hit the "OK" (which calles the
onClose() method and should cause the ActivityManager to de-registere
the "Activity"..)

Any Ideas ???

Rehgards Jesper - Running GWT 2.2.1 and it is same behavior on FF,
Chrome and Safari

Here is my code:
public class DefaultPlace extends Place {}
public class DefaultView extends Composite implements IsWidget{
    HorizontalPanel hp = new HorizontalPanel();
    Button b = new Button("Go To Example1");

    public DefaultView() {


    HasClickHandlers getButton() {
        return b;
public class DefaultActivity extends AbstractActivity implements
Activity {

    ClientFactory clientFactory;
    DefaultView defaultView;

    public DefaultActivity(DefaultPlace place, ClientFactory
clientFactory) {
        this.clientFactory = clientFactory;

    public void start(AcceptsOneWidget panel, EventBus eventBus) {
        defaultView = clientFactory.getDefaultView();
        defaultView.getButton().addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {

Beware! you have a leak here! your view is a singleton but your activity is disposable: you should remove the ClickHandler from onStop and onCancel otherwise the button keeps references to all the activities ever started!
This is why you experience a slowdown when you remove your mayStop override.

I'm afraid it's not the cause of your issue with mayStop but it's a start…

You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To view this discussion on the web visit
To post to this group, send email to
To unsubscribe from this group, send email to
For more options, visit this group at

No comments:

Post a Comment