newLISP Fan Club

Forum => newLISP Graphics & Sound => Topic started by: HPW on June 11, 2007, 09:49:57 AM

Title: GUI server restart after closing
Post by: HPW on June 11, 2007, 09:49:57 AM
I tried GUI-Server 0.3 from newLISP.dll and set:



(gs:listen true)



So my app keep open onClose.

I was not able to restart the GUI after the first close.



What is the correct way to close and to restart the GUI ?

Is it possible to use it that way?
Title:
Post by: Lutz on June 11, 2007, 10:11:52 AM
Normally the gs:listen loop will exit when communication with guiserver.jar is interrupted. The 'true flag keeps newlisp running (or in your case newlisp.dll).



But you should still be able to close the gui part (i.e. by clicking on the x icon)


QuoteI was not able to restart the GUI after the first close.


Was Java still running in Windows task manager?



Or did the network routines fail when trying to connect the second time?



Perhaps the port newlisp.dll was using have to be closed. Change the gs:listen routine in guiserver.lsp to the following:


(define (listen flag)
    (while (net-receive in 'event 100240 "n")
        (eval-string event))
    (println "server shut down")
    (if (not flag) (exit))
    (net-close listenSock)
)


If this works for dll mode let me know and I can add it.



Lutz
Title:
Post by: HPW on June 11, 2007, 12:51:12 PM
QuoteWas Java still running in Windows task manager?


No, it disappears.


QuoteOr did the network routines fail when trying to connect the second time?


Seems so.

First time it shows:
server listening on 47011
server accepted from 0.0.0.0
server connecting to 0.0.0.0:47012
server connected

Second time only:
server listening on 47011

and hanging.

Java reloads to around 15 MB instead of 23 MB the first time.

Not returning from: (load "c:/Programme/newlisp/widgets-demo.lsp")


Quote
Perhaps the port newlisp.dll was using have to be closed. Change the gs:listen routine in guiserver.lsp to the following:


Did not solve this problem.
Title:
Post by: Lutz on June 11, 2007, 02:50:14 PM
when you run a GUI app from newlis.dll how do you start it the 1st and the 2nd time? I guess you are using NeoBook to import newlisp.dll?



It looks like the newlisp.ddl doesn't try to do the net-connect the second time or fails on it for some reason.



This is not easy to debug and I will not get to this until later, completing the 2D functionality and making sure things work when invoked from the normal newlisp executable first. Perhaps you can find a workaround, unloading newlisp.dll and then loading it again?



Lutz
Title:
Post by: Lutz on June 11, 2007, 08:20:33 PM
Turns out there is a simple solution. Make the following change in 'gs:init' in guiserver.lsp:

   ...
    (set 'retry 0)
    (set 'out nil)   ; <=== add this statement
    (while (not out)
    ...


now you shoud be able to so multiple restarts from the DLL. This will be included in future versions of guiserver.lsp. You still have to put the optional 'true in (gs:listen true)



Lutz
Title:
Post by: HPW on June 11, 2007, 10:41:22 PM
Thanks Lutz,



works as expected now!



;-)