comp.lang.ada
 help / color / mirror / Atom feed
From: "ldries46" <bertus.dries@planet.nl>
Subject: Re: Problem with Saving and printing a Gtk Textbuffer
Date: Tue, 20 Nov 2018 14:12:18 +0100
Date: 2018-11-20T14:12:18+01:00	[thread overview]
Message-ID: <5bf40833$0$14959$e4fe514c@news.kpn.nl> (raw)
In-Reply-To: <5bf3c62a$0$14970$e4fe514c@news.kpn.nl>

In the mean time I made this loop working by changing the value of len. len 
was 50 lines but the loop ony works with 48 lines so I changed nr < len in 
nr < len - 1. I don't understand why this is so if anyone can tell me why or 
can give me a better solution i would be happy.

"ldries46"  schreef in bericht news:5bf3c62a$0$14970$e4fe514c@news.kpn.nl...

I have a Gtk Textbuffer with some text in it. I want to save or print the
contents of the buffer therefore I use in both cases about the same
construction with transporting to  a string in a put Line for saving and ,
as shown in the example code, to a drawbuffer used for printing.

Get_Start_Iter(Draw_Buffer, start_it);
Get_End_Iter(Draw_Buffer, end_it);
Draw_Buffer.Delete(start_it, end_it);
len := Main_Window.Output_Buffer.Get_Line_Count;
nr := 1;
while nr < len loop
   Get_Iter_At_Line(Main_Window.Output_Buffer, start, nr);
   Get_Iter_At_Line_Offset(Main_Window.Output_Buffer, stop, nr, 500);
   str := To_Unbounded_String(Main_Window.Output_Buffer.Get_Text(start,
stop));
   Num_Line := Get_Back(str);
   Draw_Buffer.Insert_At_Cursor(To_String(Num_Line.str & CRLF));
   nr := nr + 1;
end loop;

With saving after the loop is an Close statement voor the file,with printing
the the printing is initiated there.

The problem is that somewhere within the loop the program crashes and I
cannot find where.
I used exceptitons to run the program to the end and found with saving that
the file exists but is not closed. Closing the program also closes the file
and I can see that the contents of the file is correct. Before stopping the
program the operating system tells me that another program is using the file
when trying to open it with wordpad. The pproblem with printing is simular.

Who can help me?

Bertus Dries 

      reply	other threads:[~2018-11-20 13:12 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-20  8:30 Problem with Saving and printing a Gtk Textbuffer ldries46
2018-11-20 13:12 ` ldries46 [this message]
replies disabled

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