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 199384 - Stack overflow error with ClonableTopComponent
Summary: Stack overflow error with ClonableTopComponent
Status: RESOLVED INVALID
Alias: None
Product: apisupport
Classification: Unclassified
Component: Project (show other bugs)
Version: 7.0
Hardware: PC Windows XP
: P2 normal (vote)
Assignee: Jesse Glick
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-06-13 18:17 UTC by ramesh_vangala
Modified: 2011-11-16 14:29 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Stack trace (71.42 KB, text/plain)
2011-06-13 18:17 UTC, ramesh_vangala
Details

Note You need to log in before you can comment on or make changes to this bug.
Description ramesh_vangala 2011-06-13 18:17:13 UTC
Created attachment 108879 [details]
Stack trace

Our class extends ClonableTopComponent, we overridden getVisualRepresentation(). In that method we are just removing all components and adding again. Please see code below:
public JComponent getVisualRepresentation() {

      if( haveXmlErrors ) {
         jpanel.removeAll();
         jpanel.setLayout( new BorderLayout() );
         jpanel.add( errorUi, BorderLayout.CENTER );
         return jpanel;
      }
      jpanel.removeAll();
      jpanel.setLayout( new BorderLayout() );
      jpanel.add( ( JComponent )ui, BorderLayout.CENTER );
      return jpanel;
   }
It is causing stack overflow error. Please find attached stack trace.
Comment 1 Stanislav Aubrecht 2011-06-14 14:56:53 UTC
you must move the jpanel modifications out of the getVisualRepresentation() method. that method should just return the jpanel instance without any other changes to component hierarchy. multiview window has a custom focus traversal policy which calls this method frequently. changes in component hierarchy fire changes in focus manager which asks for visual representation component which leads to stack overflow.

the best place to change multiview content are MultiViewElement.componentOpened() and MultiViewElement.componentShowing() methods.
Comment 2 ramesh_vangala 2011-06-21 11:53:59 UTC
Thanks Issue fixed, Thanks alot.