comp.lang.ada
 help / color / mirror / Atom feed
* Ada newbie  + Gtkada + Win2000 = ?
@ 2007-09-16 14:11 Brian Drummond
  2007-09-16 14:53 ` Dmitry A. Kazakov
  2007-09-16 18:12 ` michael bode
  0 siblings, 2 replies; 4+ messages in thread
From: Brian Drummond @ 2007-09-16 14:11 UTC (permalink / raw)


Just trying to learn Ada; (it's somewhat familiar after years on VHDL)
and interested in making simple cross-platform Win/Linux applications...

So I built the "testgtk" example (on Win2000 SP4) with Gnat2007 and
GtkAda (2006 as recommended by Adacore) and...
well it's unreliable; I've found quite a few ways of breaking it. (The
pre-built testgdk.exe is similarly unreliable so it's not just my
build).

This is good exercise; if I use the tools for my own application, I'll
certainly have to face - and fix - problems; the ease of uncovering and
fixing problems is part of what I want from Ada.

So I have fixed some; but am having trouble with others.
I am posting because I am interested in two questions:
(a) are these problems repeatable on other systems? (maybe some are
Windows-only; maybe only my particular machine)

(b) where do I start to fix the ones I'm having trouble with?
(Not necessarily a complete solution; but an approach. I'm a total
newbie with GTK for example)


Fixed:
(1) the "Misc/Cursors" demo has a spin control with a list box. Enter an
odd number in the list box and watch...
I can see no better fix than subtracting 1 if odd in Set_Cursor (and
setting the spinner value to match), without an extensive rewrite. (Took
the opportunity to replace some magic numbers with Gdk_Cursor_Type'first
and 'last too)

(2) Composite Widgets/plot_realtime draws "outside the box".
Clip_Data(Active_Plot, True) before Add_Plot and Show seems to fix.

(3) Without "test.xpm" in the executable's directory, "Containers
handle_box" and some other demos fall over (constraint error in
"getDrawingSize").
My fix: a new package supplies a new "Create_From_Xpm" function; this
checks the file exists and substitutes a default pixmap from a constant
using Gdk_Pixmap.Create_From_Xpm_D if necessary. 
The new package also wraps the Gdk_Pixmap type so all I do is With; Use;
it in place of GDK_Pixmap, in Create_Toolbar.adb and Create_Pixmap.adb
respectively.

Not fixed:
(1) Composite Widgets/plot_3d: pressing a rotate button obscures the
other buttons. I have no idea how to proceed with this. It may be
possible for the "rotate_x/y/z" functions to emit an "expose" signal to
the buttons but that looks like the wrong answer. 
I feel there ought to be a way to alert the canvas to draw the buttons;
I'd have hoped "put"ting the buttons there would do it but apparently
not...
Or is this a bug in GtkAda underneath?

(2) Memory leaks in all the "Plot" widgets.
(a) alternately selecting "Plot" and "Plot3D" I can get memory usage up
to about 45MB before allocation fails;
(b) "Plot_Realtime" lasts about a minute before falling over (at about
18MB memory usage)
(c) "Plot_3D" leaks about 320K per press of a "Rotate" button. On the
31st press (every time I've counted!) it falls over with:
gdkgc-win32.c:846 SaveDC failed: not enough memory available to process
this command" and an Exception_Access_Violation.
This message is typical of the failures in the other widgets too.

There are two mysteries here: - why the memory leaks occur; the GTK
documentation claims it manages memory for you, and why it falls over so
early (even when there is about 500MB of free memory) - if there is some
heap limit imposed on the program, I can't see it.

(3)  "plot" has a Print button. This writes a 71K Postscript file, then
raises an Exception_Access_Violation. I haven't worked on this one at
all.

The memory leaks are concerning; it doesn't look to me as if there is a
solution at the Ada level, and the point of the exercise is to escape
from C, if possible. If I need to get the full set of GTK sources, build
them and debug, I might, but it'll take a lot longer...

Thanks in advance for any help you can offer,

- Brian



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-09-16 23:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-09-16 14:11 Ada newbie + Gtkada + Win2000 = ? Brian Drummond
2007-09-16 14:53 ` Dmitry A. Kazakov
2007-09-16 23:54   ` Brian Drummond
2007-09-16 18:12 ` michael bode

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox