Fixes NPE in PopupPanel when history is disabled. http://gwt-code-reviews.appspot.com/143814/show git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@7583 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/user/src/com/google/gwt/user/client/ui/PopupPanel.java b/user/src/com/google/gwt/user/client/ui/PopupPanel.java index 585d935..4e86561 100644 --- a/user/src/com/google/gwt/user/client/ui/PopupPanel.java +++ b/user/src/com/google/gwt/user/client/ui/PopupPanel.java
@@ -1391,11 +1391,15 @@ } } }); - } else if (nativePreviewHandlerRegistration != null) { - nativePreviewHandlerRegistration.removeHandler(); - nativePreviewHandlerRegistration = null; - historyHandlerRegistration.removeHandler(); - historyHandlerRegistration = null; + } else { + if (nativePreviewHandlerRegistration != null) { + nativePreviewHandlerRegistration.removeHandler(); + nativePreviewHandlerRegistration = null; + } + if (historyHandlerRegistration != null) { + historyHandlerRegistration.removeHandler(); + historyHandlerRegistration = null; + } } } }
diff --git a/user/test/com/google/gwt/user/client/ui/PopupHistoryDisabledTest.java b/user/test/com/google/gwt/user/client/ui/PopupHistoryDisabledTest.java new file mode 100644 index 0000000..75c3aab --- /dev/null +++ b/user/test/com/google/gwt/user/client/ui/PopupHistoryDisabledTest.java
@@ -0,0 +1,41 @@ +/* + * Copyright 2010 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.google.gwt.user.client.ui; + +import com.google.gwt.junit.DoNotRunWith; +import com.google.gwt.junit.Platform; +import com.google.gwt.junit.client.GWTTestCase; + +/** + * Tests for {@link PopupPanel} when history is disabled. + */ +@DoNotRunWith(Platform.HtmlUnit) +public class PopupHistoryDisabledTest extends GWTTestCase { + + @Override + public String getModuleName() { + return "com.google.gwt.user.HistoryDisabledTest"; + } + + /** + * Issue 4584: Make sure that we do not throw an NPE when history is disabled. + */ + public void testShowHide() { + PopupPanel p = new PopupPanel(true, false); + p.show(); + p.hide(); + } +}