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 253699 - Improved support for OpenGL content in top components
Summary: Improved support for OpenGL content in top components
Status: NEW
Alias: None
Product: platform
Classification: Unclassified
Component: Window System (show other bugs)
Version: 8.0.2
Hardware: PC Windows 7
: P3 normal (vote)
Assignee: Stanislav Aubrecht
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-07-23 19:13 UTC by tdanard
Modified: 2015-11-03 21:32 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Patch (79.14 KB, patch)
2015-11-03 21:08 UTC, rfromm
Details | Diff
Patch without formatting (3.40 KB, patch)
2015-11-03 21:32 UTC, rfromm
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description tdanard 2015-07-23 19:13:53 UTC
We have top components whose content is an OpenGL canvas.

When a user drags the tab of such top component to another monitor, we get the following stack trace:

SEVERE: null
java.lang.IllegalArgumentException: adding a container to a container on a different GraphicsDevice
	at java.awt.Component.checkGD(Component.java:1178)
	at java.awt.Container.checkGD(Container.java:1165)
	at java.awt.Container.checkGD(Container.java:1165)
	at java.awt.Container.checkGD(Container.java:1165)
	at java.awt.Container.checkGD(Container.java:1165)
	at java.awt.Container.addImpl(Container.java:1086)
	at java.awt.Container.add(Container.java:966)
	at org.netbeans.swing.tabcontrol.plaf.DefaultTabbedContainerUI.initDisplayer(DefaultTabbedContainerUI.java:632)
	at org.netbeans.swing.tabcontrol.plaf.DefaultTabbedContainerUI$ContainerHierarchyListener.hierarchyChanged(DefaultTabbedContainerUI.java:996)
	at java.awt.Component.processHierarchyEvent(Component.java:6672)
	at java.awt.Component.processEvent(Component.java:6291)
	at java.awt.Container.processEvent(Container.java:2229)
	at java.awt.Component.dispatchEventImpl(Component.java:4861)
	at java.awt.Container.dispatchEventImpl(Container.java:2287)
	at java.awt.Component.dispatchEvent(Component.java:4687)
	at java.awt.Component.createHierarchyEvents(Component.java:5521)
	at java.awt.Container.createHierarchyEvents(Container.java:1437)
	at java.awt.Container.createHierarchyEvents(Container.java:1434)
	at java.awt.Container.createHierarchyEvents(Container.java:1434)
	at java.awt.Container.createHierarchyEvents(Container.java:1434)
	at java.awt.Container.createHierarchyEvents(Container.java:1434)
	at java.awt.Component.show(Component.java:1619)
	at java.awt.Window.show(Window.java:1042)
	at java.awt.Component.show(Component.java:1651)
	at java.awt.Component.setVisible(Component.java:1603)
	at java.awt.Window.setVisible(Window.java:1014)
	at org.netbeans.core.windows.view.ViewHierarchy.updateSeparateViews(ViewHierarchy.java:376)
	at org.netbeans.core.windows.view.ViewHierarchy.updateViewHierarchy(ViewHierarchy.java:184)
	at org.netbeans.core.windows.view.DefaultView.changeGUI(DefaultView.java:156)
	at org.netbeans.core.windows.ViewRequestor.dispatchRequest(ViewRequestor.java:275)
	at org.netbeans.core.windows.ViewRequestor.processRequest(ViewRequestor.java:251)
	at org.netbeans.core.windows.ViewRequestor.postRequest(ViewRequestor.java:189)
	at org.netbeans.core.windows.ViewRequestor.scheduleRequest(ViewRequestor.java:127)
	at org.netbeans.core.windows.Central.updateViewAfterDnD(Central.java:2716)
	at org.netbeans.core.windows.Central.userDroppedTopComponentsIntoFreeArea(Central.java:2235)
	at org.netbeans.core.windows.view.DefaultView.userDroppedTopComponentsIntoFreeArea(DefaultView.java:901)
	at org.netbeans.core.windows.view.dnd.WindowDnDManager.performDrop(WindowDnDManager.java:974)
	at org.netbeans.core.windows.view.dnd.WindowDnDManager.tryPerformDrop(WindowDnDManager.java:830)
	at org.netbeans.core.windows.view.dnd.TopComponentDragSupport$3.run(TopComponentDragSupport.java:662)
	at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)
	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:727)
	at java.awt.EventQueue.access$200(EventQueue.java:103)
	at java.awt.EventQueue$3.run(EventQueue.java:688)
	at java.awt.EventQueue$3.run(EventQueue.java:686)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:697)
	at org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:159)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)

We replaced in DefaultTabbedContainerUI.java:

contentDisplayer.add(curC);

with

if (curC.getParent() != null) {
   curC.getParent().remove(curC);
}
contentDisplayer.add(curC);



And in StackLayout.java

parent.add(c);

with

if (c.getParent() != null) {
   c.getParent().remove(c);
}
parent.add(c);

And this seems to fix this issue.

There is also anecdotal evidence that it also improves the behaviour of Window->Reset Windows for OpenGL canvas.
Comment 1 rfromm 2015-11-03 21:08:54 UTC
Created attachment 157127 [details]
Patch

Here is the patch file. It does exactly what is described above; explicitly removes components from their old parents before adding them to their new ones.
Comment 2 rfromm 2015-11-03 21:32:47 UTC
Created attachment 157129 [details]
Patch without formatting

As a force of habit, I accidentally formatted the code, resulting in a large number of unnecessary changes. This file should be correct.