Field

Ticket #95 (closed defect)

Opened 4 months ago

Last modified 6 days ago

Canvas freezes on basic copy paste

Reported by: mikey Assigned to: mikey
Priority: major Milestone:
Component: core Version:
Keywords: Cc:

Description (Last modified by marc)

This is a bug I showed Marc in Boston about the canvas freezing and not displaying the python boxes that I am creating through a MouseListener?'s method. I created an interface CanvasListener? that extends KeyListener?, MouseListener?, MouseMotionListener? and I interact with it through the following code in python to be automatically executed:

from java.awt.event import KeyEvent
from field.core.plugins.history import Templating
from hyposurface.generics import CanvasListener
from field.core.plugins.python import DynamicExtensionPoint

_self.onCanvas_ = DynamicExtensionPoint(CanvasListener)
#_self.enclosingFrame.getCanvas().addMouseListener(_self.onCanvas_.getProxy())
T.addCanvasListener(_self.enclosingFrame, _self.onCanvas_.getProxy())
_a.add = 0
k = _self.onCanvas_.keyPressed
@k
def keyPressed(event):
	if (event.getKeyCode() == KeyEvent.VK_C) :
		_a.add = 1
k = _self.onCanvas_.keyReleased
@k
def keyReleased(event):
	if (event.getKeyCode() == KeyEvent.VK_C):
		_a.add = 0
m  = _self.onCanvas_.mousePressed
@m
def mousePressed(event):
	loc = _self.enclosingFrame.getCurrentMousePosition()
	_a.add = event.getClickCount() == 2
	print event.getClickCount()==2 and len(allMarked()) !=0
	if (_a.add and len(allMarked()) !=0):
		mar_ = allMarked().pop()
		newElement_ = Templating.simpleCopy(mar_,_self.root)
		newElement_.setFrame(Rect(loc.x,loc.y,50,50))
		newElement_.name=mar_.name
		newElement_.python_noEdit = 1
		newElement_.python_source_v = newElement_.python_source_v + "\n_a.series=" + mar_.name
		newElement_()

So you can mark a box, and then double click to basically copy the marked element (from any sheet), but it also adds a tag on the bottom of the python_source_v that I use in my code. I found that it only freezes when the first thing I do with the sheet that contains this code is to copy another element.

Change History

08/11/2008 07:56:32 AM changed by mikey

The freezing doesn't always happen. I am trying to figure out what property of the box makes it happen, since I think it might be dependent on the last line of the python code where i call newElement_()

08/11/2008 08:49:21 AM changed by mikey

Alright, I know what causes it. In the boxes I'm trying to copy, i call

if (_a.slider_ == None) :
	_a.slider_ = sheetSlider("foo")

So when the box is being called, _a.slider ==null, so it calls sheetSlider("foo") which causes the problem. And the error I get in the terminal seems to point to a gl instance somewhere being null I think (or from my searching around through the code).

java.lang.NullPointerException
	at field.graphics.core.AdvancedTextures$BaseFastRawTexture.setup(AdvancedTextures.java:514)
	at field.graphics.core.TextSystem$AribitraryComponent.on(TextSystem.java:154)
	at field.core.windowing.components.SwingBridgeComponent.paint(SwingBridgeComponent.java:324)
	at field.core.windowing.GLComponentWindow$ComponentContainer.paint(GLComponentWindow.java:410)
	at field.core.windowing.GLComponentWindow.display(GLComponentWindow.java)
	at field.core.windowing.GLComponentWindow$3.display(GLComponentWindow.java:758)
	at com.sun.opengl.impl.GLDrawableHelper.display(GLDrawableHelper.java:78)
	at javax.media.opengl.GLCanvas$DisplayAction.run(GLCanvas.java:435)
	at com.sun.opengl.impl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:194)
	at javax.media.opengl.GLCanvas.maybeDoSingleThreadedWorkaround(GLCanvas.java:412)
	at javax.media.opengl.GLCanvas.display(GLCanvas.java:244)
	at field.core.windowing.GLComponentWindow.update(GLComponentWindow.java)
	at field.launch.Launcher$6.actionPerformed(Launcher.java:261)
	at javax.swing.Timer.fireActionPerformed(Timer.java:271)
	at javax.swing.Timer$DoPostEvent.run(Timer.java:201)
	at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
	at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:269)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:184)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:176)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)

08/13/2008 07:29:07 AM changed by marc

  • status changed from new to assigned.
  • description changed.

Ok, that's an excellent start on tracking it down. I'm imagining that if you try to copy a box that doesn't say sheetSlider(...) (or anything else that needs texture creation) then no freeze occurs. Certainly if GLCanvas throws an NPE all bets are off concerning interactivity and responsiveness.

I think I'll have a fix soon.

08/13/2008 10:00:31 AM changed by marc

I'd appreciate it if you could give changest:151 a go.

I actually can't seem to duplicate your freeze / NPE (which I suspect is tightly coupled to the habits of your hand, we were certainly able to duplicate it in Boston). That said there was certainly a bug lurking inside Templating.simpleCopy() as it pertains to copying things which have GUI things hanging off of the side of them. Indeed, we're actually just right back to #71 --- the copy mechansim is just not clever enough.

08/17/2008 09:04:32 AM changed by mikey

  • description changed.

so i just tested it, and it still gets an error. i'm not really copying the slider, I am just copying the contents of the box, and then executing the box, which then creates the slider (the box being copied never did have a slider because the line of code to create the slider was never run). for some reason, that is where the error is.

08/20/2008 08:50:09 AM changed by marc

  • description changed.

Bah! You might have to attach both of your .field files for me to have a go at this.

(I understand that you're not copying the slider (which is the right thing to do), but the old Templating code was trying to copy the slider anyway).

08/23/2008 08:13:10 AM changed by marc

please try with changeset:162

08/24/2008 12:02:08 PM changed by mikey

  • description changed.

still doesn't work. i will attach the .field files. that makes it not work.

09/28/2008 04:12:12 PM changed by marc

  • owner changed from marc to mikey.
  • status changed from assigned to new.
  • description changed.

this might be fixed in changeset:184

11/28/2008 11:36:23 AM changed by marc

  • status changed from new to closed.
  • severity changed.