We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Page Index Toggle Pages: 1
Shutdown hooks (Read 2685 times)
Shutdown hooks
Apr 22nd, 2010, 4:16am
 
Hi,

I'd like to use processing to display some data from sensors.
While thinking about this and having a first look at processing, I did not find a way to add any shutdown hooks to free system resources.

Instead, in processing.core.PApplet.main(String[]), I found


Code:
Label label = new Label("stop");
       label.setForeground(stopColor);
       label.addMouseListener(new MouseAdapter() {
           public void mousePressed(MouseEvent e) {
             System.exit(0);
           }
         });

and
Code:

frame.addWindowListener(new WindowAdapter() {
           public void windowClosing(WindowEvent e) {
             System.exit(0);
           }
         });


which made me shiver.

Why don't you call applet.destroy() here, which lets the main thread exit gracefully instead of just shutting down the VM?

Or did I miss anything?

Regards,
Philipp
Re: Shutdown hooks
Reply #1 - May 2nd, 2010, 3:26pm
 
Philipp,
I am with you. My application draws a processing graph, but the application runs independently of the graph, and should continue to run after the graph is gone. Implicitly calling system.exit() takes not only processing but my application down too.

Did you find a workaround?

Thanks.
Rajat
Re: Shutdown hooks
Reply #2 - May 17th, 2010, 3:34am
 
Hi Rajat,

I ended up modifying thr processing-core to suit my needs and use it instead of the original version.

Too bad, none of the original developers answered on this thread as I would be willing to discuss my changes and share it to the project.
Anybody listening?
Re: Shutdown hooks
Reply #3 - May 17th, 2010, 6:39am
 
Perhaps you can hop to the Contribute page and fill in a bug report, if there is none related That's a better way to reach Processing developers.
Re: Shutdown hooks
Reply #4 - May 17th, 2010, 8:48am
 
Sorry. I usually lurk here but final exams and commencement left me without time to move on any of this. You can submit this as a bug here -- http://dev.processing.org/bugs/enter_bug.cgi?product=processing and submit your changes by zipping the source files and attaching them.

I'm not sure why the VM is shut down directly there, and I wonder if this may explain some problems I've been trying to sort out with a different bug. If you've already got a fix coded up I'd love to see it.


Edited:
Converted the text into a hyperlink
Re: Shutdown hooks
Reply #5 - May 19th, 2010, 2:58am
 
Hi,

this is the concerning bug-report: http://dev.processing.org/bugs/show_bug.cgi?id=1563

Regards,
Philipp
Page Index Toggle Pages: 1