You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by sm...@apache.org on 2012/07/26 19:44:13 UTC
svn commit: r1366104 - in /pivot/trunk:
tests/src/org/apache/pivot/tests/issues/pivot861/
wtk/src/org/apache/pivot/wtk/content/ wtk/src/org/apache/pivot/wtk/media/
wtk/src/org/apache/pivot/wtk/skin/
Author: smartini
Date: Thu Jul 26 17:44:13 2012
New Revision: 1366104
URL: http://svn.apache.org/viewvc?rev=1366104&view=rev
Log:
merge fixes from 2.0.x
Added:
pivot/trunk/tests/src/org/apache/pivot/tests/issues/pivot861/
pivot/trunk/tests/src/org/apache/pivot/tests/issues/pivot861/LeakTestWindow.java
pivot/trunk/tests/src/org/apache/pivot/tests/issues/pivot861/Pivot861.java
pivot/trunk/tests/src/org/apache/pivot/tests/issues/pivot861/TestDialog.java
pivot/trunk/tests/src/org/apache/pivot/tests/issues/pivot861/leak_test_window.bxml
pivot/trunk/tests/src/org/apache/pivot/tests/issues/pivot861/test_dialog.bxml
Modified:
pivot/trunk/wtk/src/org/apache/pivot/wtk/content/ButtonDataRenderer.java
pivot/trunk/wtk/src/org/apache/pivot/wtk/media/Picture.java
pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/WindowSkin.java
Added: pivot/trunk/tests/src/org/apache/pivot/tests/issues/pivot861/LeakTestWindow.java
URL: http://svn.apache.org/viewvc/pivot/trunk/tests/src/org/apache/pivot/tests/issues/pivot861/LeakTestWindow.java?rev=1366104&view=auto
==============================================================================
--- pivot/trunk/tests/src/org/apache/pivot/tests/issues/pivot861/LeakTestWindow.java (added)
+++ pivot/trunk/tests/src/org/apache/pivot/tests/issues/pivot861/LeakTestWindow.java Thu Jul 26 17:44:13 2012
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you 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 org.apache.pivot.tests.issues.pivot861;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.Date;
+
+import org.apache.pivot.beans.BXML;
+import org.apache.pivot.beans.BXMLSerializer;
+import org.apache.pivot.beans.Bindable;
+import org.apache.pivot.collections.Map;
+import org.apache.pivot.serialization.SerializationException;
+import org.apache.pivot.util.Resources;
+import org.apache.pivot.wtk.Action;
+import org.apache.pivot.wtk.ApplicationContext;
+import org.apache.pivot.wtk.Component;
+import org.apache.pivot.wtk.Display;
+import org.apache.pivot.wtk.PushButton;
+import org.apache.pivot.wtk.Window;
+
+/**
+ * Simple test window which continuously presses a button which opens a dialog
+ * box and then closes it immediately.
+ *
+ * Watch the heap usage in a profiler and compare:
+ * - when TestDialog has an icon (specified in ok_dialog.bxml)
+ * - when TestDialog has no icon
+ * and see that heap usage will grow to almost the maximum when an icon is used
+ * in TestDialog.
+ *
+ * The icon contains an ImageListenerList which will retain a
+ * reference to every dialog created, thus preventing them being garbage collected.
+ */
+public class LeakTestWindow extends Window implements Bindable {
+
+ private static final String MARKUP_FILE = "/org/apache/pivot/tests/issues/pivot861/leak_test_window.bxml";
+
+ @BXML
+ PushButton button;
+
+ int dialogTest = 0;
+
+ public static LeakTestWindow create() throws IOException, SerializationException {
+ System.out.println("LeakTestWindow create()");
+ return (LeakTestWindow) new BXMLSerializer().readObject(LeakTestWindow.class, MARKUP_FILE);
+ }
+
+ @Override
+ public void initialize(Map<String, Object> arg0, URL arg1, Resources arg2) {
+ System.out.println("LeakTestWindow initialize(...)\n");
+
+ button.setAction(new Action() {
+ @Override
+ public void perform(Component component) {
+ dialogTest++;
+ System.out.println("Dialog test number " + dialogTest + " at " + new Date());
+ TestDialog dialog = TestDialog.create();
+
+ System.out.println("Opening the dialog");
+ dialog.open(LeakTestWindow.this);
+
+ // Close the dialog straight away
+ System.out.println("Closing the dialog");
+ dialog.close();
+
+ System.out.println("End of perform()\n");
+ }
+ });
+ }
+
+ @Override
+ public void open(Display display, Window owner) {
+ super.open(display, owner);
+
+ ApplicationContext.scheduleCallback(new Runnable() {
+ @Override
+ public void run() {
+ while(true) {
+ button.press();
+ }
+ }
+ }, 1000 // add a little delay (instead of 0) to show the TestDialog
+ );
+ }
+
+}
Added: pivot/trunk/tests/src/org/apache/pivot/tests/issues/pivot861/Pivot861.java
URL: http://svn.apache.org/viewvc/pivot/trunk/tests/src/org/apache/pivot/tests/issues/pivot861/Pivot861.java?rev=1366104&view=auto
==============================================================================
--- pivot/trunk/tests/src/org/apache/pivot/tests/issues/pivot861/Pivot861.java (added)
+++ pivot/trunk/tests/src/org/apache/pivot/tests/issues/pivot861/Pivot861.java Thu Jul 26 17:44:13 2012
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you 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 org.apache.pivot.tests.issues.pivot861;
+
+import org.apache.pivot.collections.Map;
+import org.apache.pivot.wtk.Application;
+import org.apache.pivot.wtk.DesktopApplicationContext;
+import org.apache.pivot.wtk.Display;
+
+/**
+ * Test application to show the memory leak (the subject for this bug).
+ * For more info, look at LeakTestWindow.
+ */
+public class Pivot861 extends Application.Adapter {
+
+ public void startup(final Display display, Map<String, String> args) throws Exception {
+ System.out.println("Pivot861 startup(...)");
+ System.out.println("\n"
+ + "Attention: now the application will go in an infinite loop, to be able to see the memory leak.\n"
+ + "Note that probably you'll have to kill the application from outside (kill the Java process).\n"
+ + "\n"
+ );
+
+ // add some sleep to let users see the warning messages in console ...
+ Thread.sleep(2000);
+
+ LeakTestWindow window = LeakTestWindow.create();
+ window.open(display);
+ }
+
+ @Override
+ public boolean shutdown(boolean b) throws Exception {
+ return false;
+ }
+
+ public static void main(String[] args) {
+ DesktopApplicationContext.main(Pivot861.class, args);
+ }
+
+}
Added: pivot/trunk/tests/src/org/apache/pivot/tests/issues/pivot861/TestDialog.java
URL: http://svn.apache.org/viewvc/pivot/trunk/tests/src/org/apache/pivot/tests/issues/pivot861/TestDialog.java?rev=1366104&view=auto
==============================================================================
--- pivot/trunk/tests/src/org/apache/pivot/tests/issues/pivot861/TestDialog.java (added)
+++ pivot/trunk/tests/src/org/apache/pivot/tests/issues/pivot861/TestDialog.java Thu Jul 26 17:44:13 2012
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you 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 org.apache.pivot.tests.issues.pivot861;
+
+import java.io.IOException;
+import java.net.URL;
+
+import org.apache.pivot.beans.BXML;
+import org.apache.pivot.beans.BXMLSerializer;
+import org.apache.pivot.beans.Bindable;
+import org.apache.pivot.collections.Map;
+import org.apache.pivot.serialization.SerializationException;
+import org.apache.pivot.util.Resources;
+import org.apache.pivot.wtk.Button;
+import org.apache.pivot.wtk.ButtonPressListener;
+import org.apache.pivot.wtk.Dialog;
+import org.apache.pivot.wtk.PushButton;
+
+public class TestDialog extends Dialog implements Bindable {
+
+ private static final String DIALOG_MARKUP_FILE = "/org/apache/pivot/tests/issues/pivot861/test_dialog.bxml";
+
+ @BXML
+ private PushButton okButton;
+
+ public static TestDialog create() {
+ System.out.println("TestDialog create()");
+ TestDialog dialog = null;
+ try {
+ BXMLSerializer bxmlSerializer = new BXMLSerializer();
+ dialog = (TestDialog) bxmlSerializer.readObject(TestDialog.class, DIALOG_MARKUP_FILE);
+ } catch (IOException e) {
+ e.printStackTrace();
+ } catch (SerializationException e) {
+ e.printStackTrace();
+ }
+ return dialog;
+ }
+
+ public void initialize(Map<String, Object> namespace, URL location, Resources resources) {
+ System.out.println("TestDialog initialize(...)");
+
+ this.okButton.getButtonPressListeners().add(new ButtonPressListener() {
+ public void buttonPressed(Button button) {
+ TestDialog.this.close(true);
+ }
+ });
+
+ }
+
+}
Added: pivot/trunk/tests/src/org/apache/pivot/tests/issues/pivot861/leak_test_window.bxml
URL: http://svn.apache.org/viewvc/pivot/trunk/tests/src/org/apache/pivot/tests/issues/pivot861/leak_test_window.bxml?rev=1366104&view=auto
==============================================================================
--- pivot/trunk/tests/src/org/apache/pivot/tests/issues/pivot861/leak_test_window.bxml (added)
+++ pivot/trunk/tests/src/org/apache/pivot/tests/issues/pivot861/leak_test_window.bxml Thu Jul 26 17:44:13 2012
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to you 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.
+-->
+
+<gui:LeakTestWindow title="Leak Test Window"
+ maximized="true"
+ xmlns:bxml="http://pivot.apache.org/bxml"
+ xmlns:gui="org.apache.pivot.tests.issues.pivot861"
+ xmlns="org.apache.pivot.wtk"
+>
+
+ <BoxPane>
+ <PushButton bxml:id="button" buttonData="Click me" preferredHeight="40" preferredWidth="60"/>
+ </BoxPane>
+
+</gui:LeakTestWindow>
Added: pivot/trunk/tests/src/org/apache/pivot/tests/issues/pivot861/test_dialog.bxml
URL: http://svn.apache.org/viewvc/pivot/trunk/tests/src/org/apache/pivot/tests/issues/pivot861/test_dialog.bxml?rev=1366104&view=auto
==============================================================================
--- pivot/trunk/tests/src/org/apache/pivot/tests/issues/pivot861/test_dialog.bxml (added)
+++ pivot/trunk/tests/src/org/apache/pivot/tests/issues/pivot861/test_dialog.bxml Thu Jul 26 17:44:13 2012
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to you 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.
+-->
+
+<gui:TestDialog
+ title="Click Ok" modal="true"
+ icon="/org/apache/pivot/wtk/skin/terra/message_type-error-16x16.png"
+ xmlns:bxml="http://pivot.apache.org/bxml"
+ xmlns:content="org.apache.pivot.wtk.content"
+ xmlns:gui="org.apache.pivot.tests.issues.pivot861"
+ xmlns="org.apache.pivot.wtk"
+>
+
+ <TablePane>
+ <columns>
+ <TablePane.Column width="1*" />
+ </columns>
+
+ <TablePane.Row height="1*">
+ <Border styles="{padding:10}">
+ <BoxPane orientation="vertical" styles="{fill:true}" preferredWidth="150">
+ <Label text="Click ok" styles="{wrapText:true,font:{size:14}}"/>
+ </BoxPane>
+ </Border>
+ </TablePane.Row>
+
+ <TablePane.Row height="-1">
+ <FlowPane styles="{alignment:'center', padding:{top:5}}">
+ <PushButton bxml:id="okButton" styles="{padding:{top:3, bottom:3},minimumAspectRatio:3}">
+ <content:ButtonData text="Ok"/>
+ </PushButton>
+ </FlowPane>
+ </TablePane.Row>
+ </TablePane>
+
+</gui:TestDialog>
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/content/ButtonDataRenderer.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/content/ButtonDataRenderer.java?rev=1366104&r1=1366103&r2=1366104&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/content/ButtonDataRenderer.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/content/ButtonDataRenderer.java Thu Jul 26 17:44:13 2012
@@ -19,8 +19,8 @@ package org.apache.pivot.wtk.content;
import java.awt.Color;
import java.awt.Font;
-import org.apache.pivot.wtk.Button;
import org.apache.pivot.wtk.BoxPane;
+import org.apache.pivot.wtk.Button;
import org.apache.pivot.wtk.HorizontalAlignment;
import org.apache.pivot.wtk.ImageView;
import org.apache.pivot.wtk.Label;
@@ -74,6 +74,7 @@ public class ButtonDataRenderer extends
// Update the image view
if (icon == null) {
imageView.setVisible(false);
+ imageView.setImage(icon);
} else {
imageView.setVisible(true);
imageView.setImage(icon);
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/media/Picture.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/media/Picture.java?rev=1366104&r1=1366103&r2=1366104&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/media/Picture.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/media/Picture.java Thu Jul 26 17:44:13 2012
@@ -27,7 +27,7 @@ import java.awt.image.BufferedImage;
*/
public class Picture extends Image {
/**
- * Enum defing the algorithms to apply when resizing a picture.
+ * Enum defining the algorithms to apply when resizing a picture.
*/
public enum Interpolation {
NEAREST_NEIGHBOR,
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/WindowSkin.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/WindowSkin.java?rev=1366104&r1=1366103&r2=1366104&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/WindowSkin.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/WindowSkin.java Thu Jul 26 17:44:13 2012
@@ -175,7 +175,8 @@ public class WindowSkin extends Containe
@Override
public void windowClosed(Window window, Display display, Window owner) {
- // No-op
+ window.getIcons().remove(0, window.getIcons().getLength());
+ // invalidateComponent();
}
@Override