[gtkada] Heap corruption and other problems

Chris Sparks mr_ada at cox.net
Mon Aug 12 17:05:59 CEST 2013


Dmitry A. Kazakov wrote:
> If so, then it must be no different to what I already successfully 
> ported to cairo. So let me insist that there is no need to catch these 
> events. The major problem I faced was resizing. The "configure-event" 
> cannot be caught and allocated size never goes down for my base 
> widget, which was Gtk_Fixed_Record. I needed Gtk_Fixed_Record because 
> it had sliders superimposed on it and standard background. For 
> Gtk_Fixed_Record allocation sizes grows when you enlarge the widget's 
> container, but remains same otherwise. That problem was solved by 
> overriding get preferred width/height "virtual" operations. They are 
> no events in Gtk3, as they were in Gtk2. I found a way to override 
> them (it is in the bindings actually) and made preferred width/height 
> returning 1 pixel and it works now. 
Yes. I know now that. I don't have to catch Expose Events as Cairo takes 
care of all of the drawing and I am ok with that.  I still have to 
figure out how to get that tasking part working again as I liked how I 
could do an Update call every so many milliseconds.
>> Is your widget a descendant of Gtk_Drawing_Area_Record?
No.  I still have not chosen to use Gtk in any form and all of my code, 
and now my sample GTk3 code, still is GTK free.
> Gtk uses double buffering, so you should never experience visual 
> distortions like partial drawing and re-drawing.
So if Gtk is doing double buffering that would certain explain why I am 
seeing the visual glitches I am seeing as I am not using
double buffering (as far as I know).
> As I said, there is something wrong with the way you handle it. You 
> should simply catch "draw" and use the cairo context it comes with. 
> You may also draw on other events, e.g. doing mouse tracking, by 
> getting the context from the widget's window. Of course you should 
> keep track of that internally and be prepared to repeat exactly same 
> drawing from "draw". 
Yes. I have in my example program changed the contents of window back 
and forth between the circular text example and a box example that I 
found on the net.  It is the box drawing that seems to have issues.
> No, I used cairo from GtkAda 3.4. Prior to GtkAda 3.4 it was Damien's 
> cairo bindings, which were higher level than ones from GtkAda. I 
> ported AICWL to the GtkAda 3.4 Cairo.
I'll be glad to see you next version of AICWL as you may already found 
issues that I am not aware of in the conversion process.
> Yes, I remember some operation, but they weren't actually needed in 
> the end. What I did is a controlled Ada font type with cairo toy font 
> and pango font back-ends. Because toy and pango font interfaces have 
> nothing in common. 
I had to add in bindings for:

   function Get_Default_Root_Window return Gdk_Window;
   procedure Update_Layout (Cr : Cairo.Cairo_Context; Layout : 
Pango.Layout.Pango_Layout);
   function Create_Layout (Cr : Cairo.Cairo_Context) return 
Pango.Layout.Pango_Layout;

without the last two, I was not able to get the rotated "text" example 
to work.


Chris



More information about the gtkada mailing list