vcs icon indicating copy to clipboard operation
vcs copied to clipboard

Closing a canvas does not work properly if more than one canvas is open.

Open danlipsa opened this issue 9 years ago • 16 comments

The following script opens 4 canvases, plots the same fillarea and closes the canvases one at a time. The canvases get cleared but not closed. This does not work on Linux but works on Mac.

import vcs
import sys
import vtk

f=vcs.createfillarea()
f.x=[.2,.5,.8]
f.y=[.2,.8,.2]
f.color=["red"]

x=vcs.init()
x.plot(f)

y=vcs.init()
y.plot(f)

z=vcs.init()
z.plot(f)

w=vcs.init()
w.plot(f)


x.interact()
x.close()

y.interact()
y.close()

z.interact()
z.close()

w.interact()
w.close()

If we replace .interact() with .backend.interact() everything works fine.

danlipsa avatar Oct 07 '16 16:10 danlipsa

@doutriaux1 @aashish24 Do you have any ideas on this? I've seen this while working on vcs.js.

danlipsa avatar Oct 07 '16 16:10 danlipsa

Related issues I think: https://github.com/UV-CDAT/uvcdat/pull/2049 https://github.com/UV-CDAT/uvcdat/issues/2016 I think the problem here is that someone keeps a reference to a pipeline object, which in turn keeps a reference to the render window. This prevents the render window from being deleted.

danlipsa avatar Oct 07 '16 20:10 danlipsa

@doutriaux1 @aashish24 @chaosphere2112 This is related to the interactor attached to the render window. Without this, windows close fine. There is a way to make this work - @chaosphere2112 might already have the code.

danlipsa avatar Nov 02 '16 15:11 danlipsa

that would be in vcs-js. I think for the pure vcs, we may still have this issue. Is that correct?

aashish24 avatar Nov 02 '16 16:11 aashish24

@aashish24 pure vcs still creates an interactor if we run in foreground mode. So the problem affects both vcs.js and vcs.

danlipsa avatar Nov 02 '16 16:11 danlipsa

@chaosphere2112 @doutriaux1 @aashish24 The problem is in configurator.py

def interact(self, *args, **kargs): self.configure() self.backend.interact(*args, **kargs)

Commenting out self.configure() makes the windows close properly. Do we still want to keep this interface - this means I have to debug this or is it safe to strip it - which means I'll spend the time removing it.

danlipsa avatar Nov 02 '16 20:11 danlipsa

Ah! My code doesn't put it in Interact mode, which is why it closes correctly (I just proxy events manually to the vtkRenderWindowInteractor)

chaosphere2112 avatar Nov 02 '16 22:11 chaosphere2112

@danlipsa Actually, looks like it works regardless on my mac. Tried:

import vcs
x = vcs.init()
y = vcs.init()
x.open()
y.open()
x.interact()
"q"
y.interact()
"q"
x.close()
y.close()

and everything closed properly.

chaosphere2112 avatar Nov 02 '16 22:11 chaosphere2112

@chaosphere2112 Does the following work? So, the first window has to close, then the second window has to close.

import vcs x = vcs.init() y = vcs.init() x.open() y.open() x.interact() x.close()

y.interact() y.close()

danlipsa avatar Nov 03 '16 14:11 danlipsa

@danlipsa @chaosphere2112 I do recall an instance in the distant past (and admittedly on a devel version) that the handles got tangled, so that I had two canvases open, but when I closed the first one opened, the second one locked, or some similar situation.. It would be great to augment any existing tests to make sure similar issues aren't happening as shared objects are "locking" the ability to deal with each independent canvas..

durack1 avatar Nov 03 '16 14:11 durack1

Seems to work (though the second call to interact() doesn’t actually Start() the interactor as far as I can tell, the widgets do show up from the call to configure())

From: Dan Lipsa <[email protected]mailto:[email protected]> Reply-To: UV-CDAT/vcs <[email protected]mailto:[email protected]> Date: Thursday, November 3, 2016 at 7:05 AM To: UV-CDAT/vcs <[email protected]mailto:[email protected]> Cc: "Fries, Samuel" <[email protected]mailto:[email protected]>, Mention <[email protected]mailto:[email protected]> Subject: Re: [UV-CDAT/vcs] Closing a canvas does not work properly if more than one canvas is open. (#21)

@chaosphere2112https://github.com/chaosphere2112 Does the following work? So, the first window has to close, then the second window has to close.

import vcs x = vcs.init() y = vcs.init() x.open() y.open() x.interact() x.close()

y.interact() y.close()

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/UV-CDAT/vcs/issues/21#issuecomment-258151249, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AAr2sBHVy1Sgmfz6MOkyKxvG7FTGoK3bks5q6eoOgaJpZM4KRPOE.

chaosphere2112 avatar Nov 03 '16 15:11 chaosphere2112

@chaosphere2112 @doutriaux1 @aashish24 Indeed this works on mac. I have to press "Open Configure" first to get the interactor to receive the key Q I press but it does close one window at a time. So this seems to be a difference between vtkXOpenGLRenderWindow and vtkCocoaRenderWindow. I have not been able to reproduce it using a VTK only example.

danlipsa avatar Nov 03 '16 18:11 danlipsa

Ah! My code doesn't put it in Interact mode, which is why it closes correctly (I just proxy events manually > to the vtkRenderWindowInteractor)

@chaosphere2112 @aashish24 @doutriaux1 In this case, I'll stop working on this. The reason why I wanted to get this working is because of vcs.js. The question remains: Should we keep the "configure" interface or should we strip it? I would vote to strip it - it provides very limited functionality, and creates maintenance problems like this one. The following image is a reminder of what this interface does: configure

danlipsa avatar Nov 03 '16 20:11 danlipsa

I can see this is used in the 3D plots. We can still keep it there.

danlipsa avatar Nov 03 '16 20:11 danlipsa

@scottwittenburg it appears x.close() does not actually close the window at all.

doutriaux1 avatar Apr 09 '19 20:04 doutriaux1

Possible duplicated of (or at least related to) #403.

scottwittenburg avatar May 01 '19 18:05 scottwittenburg