Info on releasing the pubscreen lock

Have a question about our Software Developer Kit? Ask them here.

Info on releasing the pubscreen lock

Postby trixie » Thu Jul 21, 2011 8:30 pm

The Intuition autodoc (as well as the RKRM) encourages releasing the pubscreen lock after opening the window:
You needn't hold the "pubscreen lock" for the duration that your window is opened. LockPubScreen() basically has the same effect as an open visitor window: it prevents the screen from being closed.

While the information is correct, this practice can be dangerous now that
1) most programs can iconify their windows;
2) users can freely define their own "automatic" public screens using the Screens editor in Prefs.

To give an example: if a program opens on a user-defined public screen that is set to "Open/Close Automatically", the screen will get closed right after you iconify the program. The program then has nowhere to return, and naturally locks up the OS when you try to deiconify it.

The documentation, of course, says "for the duration that your window is opened". But I don't think it is made clear enough that you should keep the lock if you intend to allow your program to iconify. A warning of a situation like the above would be appropriate at least.
Smoke me a kipper, I'll be back for breakfast!
SAM440ep-flex @ 667MHz / 1GB RAM / Radeon 9250 / AmigaOS 4.1 Final Edition
User avatar
trixie
 
Posts: 357
Joined: Thu Jun 30, 2011 3:54 pm
Location: Czech Republic

Re: Info on releasing the pubscreen lock

Postby Hans-Joerg Frieden » Fri Jul 22, 2011 1:47 am

Good point. Unfortunately, a lot of documentation is still in a pre-4.0 state.

Thanks for the pointer.
NOTICE: If you want to contact me, use E-Mail. I cannot be contacted via the forum/private messages anymore
User avatar
Hans-Joerg Frieden
AmigaOS Core Developer
AmigaOS Core Developer
 
Posts: 223
Joined: Wed Dec 08, 2010 4:52 pm

Re: Info on releasing the pubscreen lock

Postby Rigo » Fri Jul 22, 2011 3:50 am

And as a result of this, I have changed window.class to now check for the validity of the screen it is supposed to open on before attempting to open.

Basically what this means is that if you unlock the pubscreen while your window is iconified, then try to open it again, it will check to make sure the screen is still around. If it is, it will open on it, if not, it will default to WorkBench.

I shall update the documentation to highlight this fact.

Thanks for the report.

Simon
User avatar
Rigo
AmigaOS Core Developer
AmigaOS Core Developer
 
Posts: 326
Joined: Mon Jan 17, 2011 10:42 pm

Re: Info on releasing the pubscreen lock

Postby tonyw » Fri Jul 22, 2011 5:57 am

To give an example: if a program opens on a user-defined public screen that is set to "Open/Close Automatically", the screen will get closed right after you iconify the program. The program then has nowhere to return, and naturally locks up the OS when you try to deiconify it.


Is that right? I just tried with the console, opened it on its own (Auto) screen, then iconified it. It closes the screen, sure, but the icon appears on the WB screen and when I double-click the icon, the Auto screen opens again. I can't see a problem with the console, anyway. IIRC it checks to make sure that the screen has the same address as before the iconification (I had to do that to make sure that DisplayBeep() worked properly). Maybe there are other programs that don't check when they reopen?
cheers
tony
User avatar
tonyw
AmigaOS Core Developer
AmigaOS Core Developer
 
Posts: 1260
Joined: Wed Mar 09, 2011 2:36 pm
Location: Sydney, Australia

Re: Info on releasing the pubscreen lock

Postby trixie » Fri Jul 22, 2011 6:36 am

@Rigo
Rigo wrote:And as a result of this, I have changed window.class to now check for the validity of the screen it is supposed to open on before attempting to open.
Basically what this means is that if you unlock the pubscreen while your window is iconified, then try to open it again, it will check to make sure the screen is still around. If it is, it will open on it, if not, it will default to WorkBench.

Thanks a lot, Simon! I was going to ask for a solution like this (very sensible I believe) but you were quicker than my thoughts :-)
Smoke me a kipper, I'll be back for breakfast!
SAM440ep-flex @ 667MHz / 1GB RAM / Radeon 9250 / AmigaOS 4.1 Final Edition
User avatar
trixie
 
Posts: 357
Joined: Thu Jun 30, 2011 3:54 pm
Location: Czech Republic

Re: Info on releasing the pubscreen lock

Postby trixie » Fri Jul 22, 2011 6:47 am

@tonyw
tonyw wrote:Is that right? I just tried with the console, opened it on its own (Auto) screen, then iconified it. It closes the screen, sure, but the icon appears on the WB screen and when I double-click the icon, the Auto screen opens again.

I guess the auto screen opens at LockPubScreen() time, so it looks like the console performs a screen check and calls LockPubScreen() again when it deiconifies.

Maybe there are other programs that don't check when they reopen?

I'm afraid there will be many of them because the documentation tells you to just release the lock after the window opens - which makes you wrongly assume that you don't have to care about it any more. This is why it's worth noting the possible trouble in the documentation, as well as describing how things should be done properly. (Sure it is me who is at fault here but had I been warned by the docs, I wouldn't have made such as stupid mistake.)
Smoke me a kipper, I'll be back for breakfast!
SAM440ep-flex @ 667MHz / 1GB RAM / Radeon 9250 / AmigaOS 4.1 Final Edition
User avatar
trixie
 
Posts: 357
Joined: Thu Jun 30, 2011 3:54 pm
Location: Czech Republic


Return to SDK Support

Who is online

Users browsing this forum: No registered users and 2 guests

cron