Path: utzoo!utgpu!watmath!att!bellcore!rutgers!usc!cs.utexas.edu!uunet!mcvax!kth!draken!tut!santra!kampi.hut.fi!jmunkki
From: jmunkki@kampi.hut.fi (Juri Munkki)
Newsgroups: comp.sys.mac.programmer
Subject: Re: A *** SERIOUS *** (but small) BUG IN SUITCASE II!
Message-ID: <24329@santra.UUCP>
Date: 9 Aug 89 17:21:16 GMT
References: <21867@andante.UUCP> <24320@santra.UUCP> <24321@santra.UUCP> <44ed4fee.19c13@locust.engin.umich.edu>
Sender: news@santra.UUCP
Reply-To: jmunkki@kampi.hut.fi (Juri Munkki)
Organization: Helsinki University of Technology, Finland
Lines: 36

In <44ed4fee.19c13@locust.engin.umich.edu> mystone@sol.engin.umich.edu writes:
>In article <24321@santra.UUCP> jmunkki@kampi.hut.fi (Juri Munkki) writes:
>>StartSetup();	/* This calls InitWindows among other things.	*/
>>GetPort(&WindowManagerPort);
>>
>>do /* my main event loop */
>>{	/*	The following line fixes a bug in Suitcase:	*/
>>	if(thePort != WindowManagerPort)	SetPort(WindowManagerPort);
>>...
>
>  It works, but i wouldn't call it optimizing.  If you're setting the port
>to the Window Manager port every time the current port isn't the Window
>Manager's port, you're going to have to set the port to a window's grafPort
>every time you want to do any drawing.  If you're going to do that anyway, the
>conditional seems to be excess baggage.  (And you shouldn't be drawing to the
>Window Manager port anyway, if you are...)

The SetPort only happens when a DA or Suitcase (or something else) changes
thePort. My own routines always use GetPort/SetPort/Draw/SetPort. That's
why the bug was causing me so much trouble (a crash/week).

I'm not doing any drawing in the window manager port. I'm not even using
the window manager port. I just set thePort to point to that so that some
buggy DAs/FKEYs/... can have a grafport to play with (to create regions for
example). My own program always calls SetPort before drawing anything.
The alternative to the code above would have been to call SetPort every
time through the event loop.

Why do I have to call SetPort every time I want to draw something? If
DAs can change thePort, then I can't rely that my port setting will
remain when I call GetNextEvent/SystemTask.

_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
|     Juri Munkki jmunkki@hut.fi  jmunkki@fingate.bitnet        I Want   Ne   |
|     Helsinki University of Technology Computing Centre        My Own   XT   |
^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^