From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=0.3 required=5.0 tests=BAYES_00,STOX_REPLY_TYPE, STOX_REPLY_TYPE_WITHOUT_QUOTES,XPRIO autolearn=no autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!feeder.eternal-september.org!news.uzoreto.com!feeder.erje.net!2.eu.feeder.erje.net!feeds.phibee-telecom.net!border2.nntp.ams1.giganews.com!nntp.giganews.com!newsfeed.xs4all.nl!newsfeed9.news.xs4all.nl!nzpost2.xs4all.net!news.kpn.nl!not-for-mail From: "ldries46" Newsgroups: comp.lang.ada Subject: Problem with Saving and printing a Gtk Textbuffer Date: Tue, 20 Nov 2018 09:30:35 +0100 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal Importance: Normal X-Newsreader: Microsoft Windows Live Mail 16.4.3528.331 X-MimeOLE: Produced By Microsoft MimeOLE V16.4.3528.331 Message-ID: <5bf3c62a$0$14970$e4fe514c@news.kpn.nl> NNTP-Posting-Host: 9f2d0c73.news.kpn.nl X-Trace: G=V58XBiOH,C=U2FsdGVkX19j3Wh1owLoxFq7q6VHiiGWEtZIOWlCRwv20/OdLpXzxbMOxKVV031e8bHQPc5sIXd0bWXrnJDUpgEJXn1pjDcUqiM3BWD0yuo= X-Complaints-To: abuse@kpn.nl Xref: reader01.eternal-september.org comp.lang.ada:54848 Date: 2018-11-20T09:30:35+01:00 List-Id: 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