This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 210428 - Scene.validate() causes always a expensive ComponentWidget.ComponentWrapper.setBounds()
Summary: Scene.validate() causes always a expensive ComponentWidget.ComponentWrapper.s...
Status: NEW
Alias: None
Product: platform
Classification: Unclassified
Component: Graph (show other bugs)
Version: 6.x
Hardware: PC Windows 7
: P3 normal (vote)
Assignee: issues@platform
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-03-30 12:40 UTC by jmichelberger
Modified: 2012-03-30 12:40 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Patch (987 bytes, application/octet-stream)
2012-03-30 12:40 UTC, jmichelberger
Details

Note You need to log in before you can comment on or make changes to this bug.
Description jmichelberger 2012-03-30 12:40:08 UTC
Created attachment 117542 [details]
Patch

ComponentWidgets are attached as sceneListeners via its ComponentSceneListener to the Scene and a Scene.validate() call notifies the ComponentSceneListener.sceneValidated() triggering ComponentWidget.addComponent().
ComponentWidget.addComponent() sets always the new calculated Bounds to the wrapped Component, even new Bounds are equal to current set Bounds. Inside Component.setBounds() there is no check to avoid subsequent setting with same Bounds and it will always end in a expensive recalculation hell. See Component.setBounds() code.

Appended patch will avoid this call if there are no changes in new calculated Bounds.

Index: ComponentWidget.java
===================================================================
--- ComponentWidget.java	(revision 159)
+++ ComponentWidget.java	(working copy)
@@ -173,9 +173,12 @@
             component.addComponentListener (componentListener);
             componentAdded = true;
         }
-        component.removeComponentListener (componentListener);
-        componentWrapper.setBounds(scene.convertSceneToView(convertLocalToScene(getClientArea())));
-        component.addComponentListener (componentListener);
+        Rectangle newBounds = scene.convertSceneToView(convertLocalToScene(getClientArea()));
+        if (!newBounds.equals(componentWrapper.getBounds())) {
+            component.removeComponentListener (componentListener);
+            componentWrapper.setBounds(scene.convertSceneToView(convertLocalToScene(getClientArea())));
+            component.addComponentListener (componentListener);
+        }
         component.repaint();
     }