Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: HITextView not showing? - SOLVED



On 1/18/06 8:03 PM, Mike Hore didst favor us with:

> Hi again Larry et al,
> 
> Problem solved.  This was a legacy app, and just after my CreateNewWindow
> call there was some code that included a SetPort call (using the WindowRef
> as its parameter, since I was assuming a WindowRef is the same as a
> GrafPtr...)

Assumptions are evil.

A little research, while taking more time than assuming, is far more
effective. ;-)
> 
> Anyway if I comment that line out, everything works.  Apparently SetPort
> calls are not just unnecessary, they're harmful!

They're fine if they're done properly.

> In this case the crash
> didn't happen when SetPort was executed, but later when I clicked on
> the window.  So it looks like SetPort is quietly corrupting the window's
> internal info.  Nasty...

Looks like you haven't done your homework. WindowRefs, ControlRefs, MenuRefs
et al became opaque in Carbon and a WindowRef is no longer a GrafPtr. Those
C-style casts that do stuff like cast WindowPtrs to GrafPtrs are indeed
nasty. If you read through the appropriate headers you'll see stuff like
this in MacWindows.h:

extern CGrafPtr 
GetWindowPort(WindowRef window)
AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER;

and

 *  SetPortWindowPort()
 *  
 *  Discussion:
 *    set the current QuickDraw port to the port associated with the
 *    window

In the long run I think it takes less time to do research *before* coding.
;-)  The opaque structures => need to use accessors is one of the most basic
issues involved in porting an application to Carbon.

Larry

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Carbon-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/carbon-dev/email@hidden

This email sent to email@hidden

References: 
 >Re: HITextView not showing? - SOLVED (From: Mike Hore <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.