English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Language > Coders. C/C++

 
 
Thread Tools
Old 01 September 2017, 19:27   #21
alkis
Registered User
 
Join Date: Dec 2010
Location: Athens/Greece
Age: 53
Posts: 719
No obvious bug in the segment of the source code you posted. From your description, the bug most probably exists in where you handle the window events and/or your shutdown code.
alkis is offline  
Old 03 September 2017, 20:04   #22
chocsplease
Registered User
 
Join Date: Dec 2016
Location: london
Posts: 178
OK I've found out how to reproduce the crash consistently. It happens if you move or resize the window while its in the update code (win_write). What I don't know is how to prevent this. It looks like its some kind of race condition.

I seem to remember reading something about this on a web site but cannot remember where or if there was a solution.

I guess I'll have to stop the Amiga responding to messages while the window is updating? But how do I do that??

Anyone any ideas?
chocsplease is offline  
Old 03 September 2017, 20:32   #23
mark_k
Registered User
 
Join Date: Aug 2004
Location:
Posts: 3,335
You can use IDCMP_SIZEVERIFY or better, IDCMP_CHANGEWINDOW to be notified when the window is about to be resized or moved.
mark_k is offline  
Old 12 September 2017, 11:54   #24
chocsplease
Registered User
 
Join Date: Dec 2016
Location: london
Posts: 178
Quote:
Originally Posted by mark_k View Post
You can use IDCMP_SIZEVERIFY or better, IDCMP_CHANGEWINDOW to be notified when the window is about to be resized or moved.
Hi Many thanks for the reply and sorry its taken a while to get back.

I'm not sure I can use IDCMP_SIZEVERIFY as having read up on it there is a warning about using AmigaDos functions inside a routine that is called by SIZEVERIFY, or any of the verify functions as AmigDos could display a requester and wait for this while my code is waiting for dos, result - deadlock.

I'm asking for messages when the user switches floppy disks, which could result in the AmigaDos - you must replace disk foo in drive whatever requester.

I am using IDCMP_NEWSIZE, and will change this to IDCMP_CHANGEWINDOW, however I cannot find anything that will allow me to queue this message (like the verify functions do) so am wondering if I will still get my problem when the user resizes the window while it is still updating?

I thought about using modifyIDCMP and clearing the messages at the start of the update, but this will result in me loosing the disk change messages etc.

I've found the Forbid, Permit pair - would this solve the problem? It seems a bit heavy handed to stop all multitasking but the net does suggest that they will prevent the sort of race condition I am running into.

Anyone any thoughts?

Thanks in advance and sorry for such a long post.
chocsplease is offline  
Old 12 September 2017, 17:51   #25
alkis
Registered User
 
Join Date: Dec 2010
Location: Athens/Greece
Age: 53
Posts: 719
I think it would help if you write up a minimum C source (fully compilable) that exhibits the problem.
alkis is offline  
Old 20 September 2017, 17:11   #26
chocsplease
Registered User
 
Join Date: Dec 2016
Location: london
Posts: 178
Quote:
Originally Posted by alkis View Post
I think it would help if you write up a minimum C source (fully compilable) that exhibits the problem.
Hi and many thanks for the suggestion.

I have built a framework of code that runs the function(s) that crash, though I confess I do not know what you are referring to when you say it should be fully compatible. Compatible with what please? All kickstarts? All versions of AmigaDos? Sorry I am at a loss here.

Anyway the below pastebin link is to the code.

https://pastebin.com/45CRLU5W

I'm afraid its still almost 700 lines - though many are blank - despite being a framework.

I compile using gcc -s - lamiga - noixemul -O2.

Run in the shell with at least a 16 colour display.

The crash occurs if you change the window while it is updating, that is text is being generated in the shell/window. If you change the window outside this then there is no crash.

I'm stumped Forbid()/Permit() do not have any effect but the Amiga locks solid and I have to reset.

I just hope someone can see where I am going wrong.

Here's hoping anyway.
chocsplease is offline  
Old 20 September 2017, 17:33   #27
alkis
Registered User
 
Join Date: Dec 2010
Location: Athens/Greece
Age: 53
Posts: 719
If you remove ALL printfs (just printf) from inside write_win() it doesn't lock up anymore (at least in my tests).

Can you please check if that fixes your problem?

PS: the word was compilable as "I can compile it and produce an executable to check"
alkis is offline  
Old 20 September 2017, 18:37   #28
chocsplease
Registered User
 
Join Date: Dec 2016
Location: london
Posts: 178
Quote:
Originally Posted by alkis View Post
If you remove ALL printfs (just printf) from inside write_win() it doesn't lock up anymore (at least in my tests).

Can you please check if that fixes your problem?

PS: the word was compilable as "I can compile it and produce an executable to check"
Many thanks - I've had it still crash in the past - but randomly since it appears to depend on if you adjust the window while the the write win function is writing - I was adding the printfs partly to find out where it crashed, and partly to slow the function down, is there a way of doing this without using printfs?

Without the printfs the function runs so quickly that it is v hard to adjust the window while the code is inside write_win.

As for compilable, compatible -oops
chocsplease is offline  
Old 21 September 2017, 00:41   #29
chocsplease
Registered User
 
Join Date: Dec 2016
Location: london
Posts: 178
Well that was unexpected.

For some reason the test code I have posted is not crashing with the printfs removed from the write_win function - I tried with Printfs and it still crashed. I'm baffled as to why but will back copy this code into the original and see what happens.

I am getting a glitch however.

Sometimes if you resize the window and it is updating the text will either overwrite the border, or not update in the whole window - there will be blank rectangles.

I'm guessing this is an update/region issue but not knowing enough about these I'm struggling to locate the problem.

I thought I could prevent the window from being resized during an update by setting mywindow->MaxHeight to the current height and mywindow->MaxWidth to the current width, however this is not working.

Is there any way of temporarily freezing a window's size once it has been opened?
chocsplease is offline  
Old 24 September 2017, 14:38   #30
chocsplease
Registered User
 
Join Date: Dec 2016
Location: london
Posts: 178
Ok I think I've fixed it by adding called to WindowsLimits at the start of the update routine (setting the limits to the current window size) and at the end (setting them to the old values).

Testing looks like it works and I no-longer get the problems where the window has blank rectangles or the text goes over the borders.

Now all I need to do is figure out how to get scoll bars to work - which I will post a new thread for as it's a different subject.
chocsplease is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Trying the get bold, italic and coloured text out to the shell window. chocsplease Coders. C/C++ 16 22 June 2017 14:58
Simple and ugly text wrapping routine rockersuke Coders. AMOS 7 21 November 2014 22:31
How can I do I/O redirection to a simple console window? Leffmann Coders. System 5 26 October 2014 23:42
Searching for a simple Text Editor Morbane request.Apps 2 01 January 2012 01:05
Standard output window Rixa support.Apps 5 17 January 2008 23:36

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 10:09.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.17390 seconds with 15 queries