[net.micro.mac] TransSkel1.0 Bug

dubois@uwmacc.UUCP (Paul DuBois) (08/28/86)

There's a bug in the window growing code of TransSkel (DoGrow) - after
a window is grown, the entire port is invalidated, which causes an
update event to be generated for the window.  The host is then notified
that the window was resized.  Fortuitously, due to the way TransSkel
operates, the current port is virtually always set to the window that
is resized.  Under certain circumstances, however, it won't be, and a
bomb occurs.  The fix is to set the port before invalidating it.  This
also explains what (to me, anyway) was an otherwise inexplicable
phenomenon in DoActivate.

The patches to (a) correct DoGrow and (b) restore DoActivate to a
more aesthetic state follow.



In DoGrow, Change:
------------------

-	if (growRes)	/* non-zero if size change */
-	{
-		SizeWindow (thePort, LoWord (growRes), HiWord (growRes), false);
-		InvalRect (&thePort->portRect);	/* force update */
-		if (h != nil)
-			(**h).whSized = true;
-	}

To:
---

+	if (growRes)	/* non-zero if size change */
+	{
+		SizeWindow (thePort, LoWord (growRes), HiWord (growRes), false);
+		SetPort (thePort);
+		InvalRect (&thePort->portRect);	/* force update */
+		if (h != nil)
+			(**h).whSized = true;
+	}

Change:
-------

-/*
-	Pass activate/deactivate notification to handler.
-
-	Oddity:  if the handler has nil update and activate procs, then
-	if I say
-	
-		if ((h != nil) && ((p = (**h).whActivate) != nil))
-		{
-			SetPort ((**h).whWind);
-			(*p) (active);
-		}
-	
-	I get a bomb after growing the window.  Apparently the port must
-	be set EVEN IF the handler ignores activates.
-	???  I don't understand why this should be.
-*/
-
-static DoActivate (h, active)
-WHandler	**h;
-Boolean		active;
-
-{
-ProcPtr	p;
-
-	if (h != nil)
-	{
-		SetPort ((**h).whWind);
-		if ((p = (**h).whActivate) != nil)
-			(*p) (active);
-	}
-}

To:
---

+/*
+	Pass activate/deactivate notification to handler.
+*/
+
+static DoActivate (h, active)
+WHandler	**h;
+Boolean		active;
+
+{
+ProcPtr	p;
+
+	if ((h != nil) && ((p = (**h).whActivate) != nil))
+	{
+		SetPort ((**h).whWind);
+		(*p) (active);
+	}
+}
-- 
Paul DuBois     UUCP: {allegra,ihnp4,seismo}!uwvax!uwmacc!dubois    |
                ARPA: dubois@easter                               --+--
                                                                    |
Begin at my sanctuary...                                            |
                          Ezekiel 9:6

wca@ut-ngp.UUCP (William C. Anderson) (08/28/86)

In article <212@uwmacc.UUCP>, dubois@uwmacc.UUCP (Paul DuBois) writes:
> 
> There's a bug in the window growing code of TransSkel (DoGrow) - after
> a window is grown, the entire port is invalidated, which causes an
> update event to be generated for the window.  The host is then notified
> that the window was resized.  Fortuitously, due to the way TransSkel
> operates, the current port is virtually always set to the window that
> is resized.  Under certain circumstances, however, it won't be, and a
> bomb occurs.  The fix is to set the port before invalidating it.  This
> also explains what (to me, anyway) was an otherwise inexplicable
> phenomenon in DoActivate.
> 
> <the patch itself>

I hope that this explains why my scrollbars were flashing _twice_ when I
expose a window! :-)  

By the way, I think that TransSkel is a *wonderful* piece of code!  It has
simplified my Mac programming greatly and it motivated me to buy LightSpeed
C (a decision that I will never regret).  TransSkel is for the Mac what
SunView is for Sun Workstations - a much simpler way to utilize the inter-
face from the programmer's point of view.

Thanks for TransSkel, Paul.

William Anderson - University of Texas Computation Center