[GRASS5] PNG driver problem

Glynn Clements glynn.clements at virgin.net
Mon Aug 23 22:44:32 EDT 2004

David Piasecki wrote:

> I am using the PNG graphics driver in a C++ application that I am 
> writing. At the click of a button, I can zoom in and out by starting 
> the PNG driver, sending region and display commands to GRASS, and 
> stopping the PNG driver. When I behave like a normal user, it seems to 
> work just fine. However, when I try to break my code by clicking the 
> zoom button about 30-50 times in quick succession, I will eventually 
> get the message that the PNG driver is already running, even though the 
> output to the terminal window has verified that the PNG driver has 
> terminated. Is it possible to get such an error message if "d.mon 
> start=PNG" is called too quickly after "d.mon stop=PNG"?

d.mon stop=..." runs mon.stop, which calls R_kill_driver() then exits. 
R_kill_driver() sends a GRAPH_CLOSE code to the driver, then calls
R_release_driver(), which close()s the socket then returns.

Nothing in this chain waits for the driver to close its end of the
connection, so the driver could still be running after "d.mon
stop=..." has completed (this is more likely to occur with the PNG
driver, as it has to write out the image before it terminates).

BTW, the latest CVS version of the PNG driver has an option to write
the image file after each command. This eliminates the need to stop
and re-start the driver in order to get the image. It also allows you
to create (binary) PPM images as an alternative to PNG.

Glynn Clements <glynn.clements at virgin.net>

More information about the grass-dev mailing list