TweetFollow Us on Twitter

May 95 Tips
Volume Number:11
Issue Number:5
Column Tag:Tips & Tidbits

Tips & Tidbits

By Scott T Boyd, Editor

Note: Source code files accompanying article are located on MacTech CD-ROM or source code disks.


Flush Out Your Bugs

Before releasing an application to your testers, load these three extensions: EBBE (Even Better Bus Error), DisposeResource, and DoubleTrouble. They check for NIL dereferences, improperly-disposed resources, and multiply-disposed memory manager blocks. [You can find these extensions in many places, including our ftp and other online sites - Ed stb] Run your application. You may be surpised at what you find.

Using these debugging tools, I caught a bug in an application based on the 1/18/95 release of Sprocket. This bug was fixed in the 1/25/95 Sprocket release, and does not exist in the 12/94 release. I’m using this code both as an example and a suggested patch if you are using the 1/18 version of Sprocket.

        if (fSplashPicture)
                DisposeHandle((Handle) fSplashPicture);  // Oops!

        WindowPtr       newFrontWindow = nil;
        if (FrontNonFloatingWindow() == fWindow)
          newFrontWindow = (WindowPtr)((WindowPeek)fWindow)->nextWindow;
        if (newFrontWindow)
        return true;

When I ran the executable, I dropped into my low level debugger, and looked at the stack. Return addresses on the stack from the MacsBug stack crawl sc7:

  Stack Addr  Frame Addr   Caller
   01C6ECD0               01B6D6D2 'CODE 0001 2690 Sprocket Lib'+0172
   01C6ECC8               01B6D692 'CODE 0001 2690 Sprocket Lib'+0132
   01C6ECAA    01C6ECA6   01B6E9F8 main+01F2
   01C6EC9E    01C6EC9A   01B6EF7A TSplashWindow::~TSplashWindow()+002C
   01C6EC88               01B6FA3C TWindow::Close()+0034
   01C6EC80    01C6EC7C   408578C4 _DisposeWindow+0004
   01C6EC6C               4085A846 _FrontWindow+0096
   01C6EC54               40877EB4 _KillPicture+0004
   01C6EC40               4085785C _NewWindow+010C
   01C6EC34               40877EB4 _KillPicture+0004
   01C6EC30               4085785C _NewWindow+010C

From this stack trace I saw that fSplashPicture got disposed again by DisposeWindow(fWindow); A review of the code showed the offending extra Dispose in ~TSplashWindow().

Why not leave these debugging resources on your system all the time? Well, it appears that not everyone uses these tools religiously and several other of my favorite (nameless) applications write to location Zero and trigger EBBE. I’ve sent in bug reports to the offenders, but I am still waiting for all the update releases.

Happy Bug Trails!

- Gary W. Powell

Powering Up The RTM Instruction

For you power programmers out there, here’s a little tip on taking advantage of the PowerPC architecture. Where you might have used the 68020 RTM instruction (Return from Module), you can get a lot of mileage by using the new PowerPC RTFM instruction instead. We can assure you that you will save literally hours of time.

- David Gorkan and Allan Foster

Save a Little Time

Here is a great and easy way to supercharge File Open... File Save and File Save As... operations from any application, especially if you use the Apple Menu Items to store aliases to folders: Make an alias of the Apple Menu Items folder and put it on the Desktop.

What does that get you? Well, since the Standard file Get and Put Dialogs all have a Desktop button, you can easily get to the Apple Menu Items, and hence access any aliases that are stored there. Just Click on the Desktop folder and the Apple Menu Item Alias appears as a supercharged Volume of Aliases.

But wait, there’s more! You get a real bonus from using System 7.5 because, if you put the Apple Menu Items alias onto the desktop, System 7.5 maintains automated folders, so the Apple Menu Items Alias can be used to get to “Recent Documents”. The “Recent Servers” can be used to log onto to any server without leaving the application that you are running.

- Mark Tillinghast
XXCAL, Testing And Systems Division

Debugging For Fun and Profit

When you have routines that return OSErrs, finish them with the following bit of code:

ReportError ( err );
return err;

which is defined as:

#ifdef qDEBUG
#define ReportError(err) do { if (err != noErr ) DebugStr ( “
\pError” ); } while (false)
#define ReportError(err)  /* nothing */

With this macro, you can tell every time that one of your routines returns an error, and it’s easy to follow your error handling code.

- Marshall Clow
Aladdin Systems

What’s My Modifier?

To quickly get the status of modifier keys, use these simple lines:

typedef struct kbd_bits {
 int command : 1;
 int : 5;
 int space : 1;
 int tab : 1;
 int : 4;
 control : 1;
 option : 1;
 capslock : 1;
 shift : 1;
} kbd_bits;

#define KeyModifiers (*(kbd_bits *)0x17A)

Then you can say simply:

if (KeyModifiers.control) {
 Debugger(); // drop into a debugger

This works across all Macs, including foreign versions and keyboard maps. For maximum compatibility with a minimal speed hit, call GetOSEvent with a null event mask and examine the modifiers field of the event returned.

- Jorg Brown
The Mac Group


Community Search:
MacTech Search:

Software Updates via MacUpdate

Markly 1.5.3 - Create measurement and de...
Markly is a measurement and design-spec plugin/extension for Photoshop and Sketch. It is made for modern Web designers and app front-end developers. You can add specification marks simply by clicking... Read more
Suitcase Fusion 6 17.3.0 - Font manageme...
Suitcase Fusion 6 is the creative professional's font manager. Every professional font manager should deliver the basics: spectacular previews, powerful search tools, and efficient font organization... Read more
Nisus Writer Pro 2.1.2 - Multilingual wo...
Nisus Writer Pro is a powerful multilingual word processor, similar to its entry level products, but brings new features such as table of contents, indexing, bookmarks, widow and orphan control,... Read more
calibre 2.40.0 - Complete e-book library...
Calibre is a complete e-book library manager. Organize your collection, convert your books to multiple formats, and sync with all of your devices. Let Calibre be your multi-tasking digital librarian... Read more
Vivaldi - An advanced browser...
Vivaldi is a browser for our friends. In 1994, two programmers started working on a web browser. Our idea was to make a really fast browser, capable of running on limited hardware, keeping in mind... Read more
OmniPlan 3.0 - Robust project management...
With OmniPlan, you can create logical, manageable project plans with Gantt charts, schedules, summaries, milestones, and critical paths. Break down the tasks needed to make your project a success,... Read more
Yummy FTP 1.11 - FTP/SFTP/FTPS client fo...
Yummy FTP is an FTP + SFTP + FTPS file transfer client which focuses on speed, reliability and productivity. Whether you need to transfer a few files or a few thousand, schedule automatic backups, or... Read more
Tweetbot 2.1 - Popular Twitter client. (...
Tweetbot is a full-featured OS X Twitter client with a lot of personality. Whether it's the meticulously-crafted interface, sounds and animation, or features like multiple timelines and column views... Read more
MacPilot 8.0 - Enable over 1,200 hidden...
MacPilot gives you the power of UNIX and the simplicity of Macintosh, which means a phenomenal amount of untapped power in your hands! Use MacPilot to unlock over 1,200 features, and access them all... Read more
Typinator 6.7 - Speedy and reliable text...
Typinator turbo-charges your typing productivity. Type a little. Typinator does the rest. We've all faced projects that require repetitive typing tasks. With Typinator, you can store commonly used... Read more

Balloony Land offers a fresh twist on th...
Balloony Land by Palringo offers a fresh twist on the match three genre and is out now on iOS and Android. First-off, you'll be popping balloons instead of crushing candy and the balloons will float up and fill the empty spaces instead of dropping... | Read more »
Graphic - vector illustration and design...
Graphic - vector illustration and design 1.0 Device: iOS iPhone Category: Productivity Price: $2.99, Version: 1.0 (iTunes) Description: Autodesk Graphic is a powerful full-featured vector drawing and illustration application right in... | Read more »
Sago Mini Babies (Education)
Sago Mini Babies 1.0 Device: iOS Universal Category: Education Price: $2.99, Version: 1.0 (iTunes) Description: Introducing the Sago Mini babies. Boys and girls love caring for these adorable characters. Feed Robin her favorite mush... | Read more »
PAUSE - Relaxation at your fingertip (H...
PAUSE - Relaxation at your fingertip 1.1 Device: iOS iPhone Category: Healthcare & Fitness Price: $1.99, Version: 1.1 (iTunes) Description: | Read more »
Super Sharp (Games)
Super Sharp 1.1 Device: iOS Universal Category: Games Price: $1.99, Version: 1.1 (iTunes) Description: Your finger has never been so sharp! Cut with skill to complete the 120 ingenious physics levels of Super Sharp and become a cut... | Read more »
Assembly - Graphic design for everyone...
Assembly - Graphic design for everyone 1.0 Device: iOS Universal Category: Photography Price: $2.99, Version: 1.0 (iTunes) Description: Assembly is the easiest most powerful design tool on the App Store. Create anything you can... | Read more »
Dub Dash (Games)
Dub Dash 1.0 Device: iOS Universal Category: Games Price: $1.99, Version: 1.0 (iTunes) Description: ARE YOU READY FOR THE ULTIMATE CHALLENGE? UNIQUE SYMBIOSIS OF MUSIC AND GRAPHICS | Read more »
Leave Me Alone (Games)
Leave Me Alone 1.0 Device: iOS Universal Category: Games Price: $1.99, Version: 1.0 (iTunes) Description: 33% off launch sale!!! Somewhere between the 1980s and 1990s there exists a world that never was. A world of skatepunks,... | Read more »
YAMGUN (Games)
YAMGUN 1.0 Device: iOS Universal Category: Games Price: $2.99, Version: 1.0 (iTunes) Description: The invasion has begun! Protect the walls of the citadel against waves of enemies! But watch out, you will soon run out of ammo...... | Read more »
Chesh (Games)
Chesh 1.0 Device: iOS Universal Category: Games Price: $2.99, Version: 1.0 (iTunes) Description: It’s like chess, only not at all. ***40% off for a limited time to celebrate our launch!*** Chesh is a game of skill, strategy, luck,... | Read more »

Price Scanner via

TP-LINK Next-Gen Routers Support a Large Numb...
TP-LINK, specialists in consumer and business networking products, have announced the availability of Archer C2600, the company’s next-generation router featuring wireless AC, multi-user MIMO, and 4-... Read more
Apple’s Education discount saves up to $300 o...
Purchase a new Mac or iPad using Apple’s Education Store and take up to $300 off MSRP. All teachers, students, and staff of any educational institution qualify for the discount. Shipping is free, and... Read more
Save up to $350 with Apple refurbished iMacs
Apple has Certified Refurbished iMacs available for up to $350 off the cost of new models. Apple’s one-year warranty is standard, and shipping is free: - 27″ 3.5GHz 5K iMac – $1949 $350 off MSRP - 27... Read more
Mac Pros on sale for up to $300 off MSRP
B&H Photo has Mac Pros on sale for up to $300 off MSRP. Shipping is free, and B&H charges sales tax in NY only: - 3.7GHz 4-core Mac Pro: $2818.99, $181 off MSRP - 3.5GHz 6-core Mac Pro: $3699... Read more
5K iMacs on sale for up to $150 off MSRP, fre...
B&H Photo has the 27″ 3.3GHz 5K iMac on sale for $1899.99 including free shipping plus NY tax only. Their price is $100 off MSRP. They have the 27″ 3.5GHz 5K iMac on sale for $2149, $150 off MSRP... Read more
Twelve South Redesigns BookArc For Today’s Sm...
Twelve South has announced a redesigned version of their very first product, BookArc for MacBook. Tailored specifically for the newest generation of MacBooks, BookArc holds the new, smaller Apple... Read more
Phone 6s Tips & Tricks – Tips Book For iP...
Poole, United Kingdom based Tap Guides Ltd. has announced the release and immediate availability of iPhone 6s Tips & Tricks, an in-depth eBook available in the iBookstore that’s priced just $2.99... Read more
Apple refurbished 2014 13-inch Retina MacBook...
Apple has Certified Refurbished 2014 13″ Retina MacBook Pros available for up to $400 off original MSRP, starting at $979. An Apple one-year warranty is included with each model, and shipping is free... Read more
13-inch 2.5GHz MacBook Pro on sale for $994,...
Best Buy has the 13″ 2.5GHz MacBook Pro available for $994.99 on their online store. Choose free shipping or free instant local store pickup (if available). Their price is $105 off MSRP. Price valid... Read more
Is The iPad Pro Really A Serious Laptop Repla...
Probably not, at least for productive professionals and other power users. Steve Jobs declared that we’d entered the “post-PC Era” with the advent of the original iPad in 2010, a phrase we don’t hear... Read more

Jobs Board

*Apple* Retail - Multiple Positions (US) - A...
Sales Specialist - Retail Customer Service and Sales Transform Apple Store visitors into loyal Apple customers. When customers enter the store, you're also the Read more
*Apple* Retail - Multiple Positions (US) - A...
Job Description:SalesSpecialist - Retail Customer Service and SalesTransform Apple Store visitors into loyal Apple customers. When customers enter the store, you're Read more
*Apple* Solutions Consultant -Bilingual, Chi...
**Job Summary** As an Apple Solutions Consultant (ASC) you are the link between our customers and our products. Your role is to drive the Apple business in a retail Read more
*Apple* Solutions Consultant - Retail Sales...
**Job Summary** As an Apple Solutions Consultant (ASC) you are the link between our customers and our products. Your role is to drive the Apple business in a retail Read more
SW QA Engineer - *Apple* TV - Apple (United...
**Job Summary** The Apple TV team is looking for experienced Quality Assurance Engineers with a passion for delivering first in class home entertainment solutions. **Key Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.