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.

TIP OF THE MONTH

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.

TSplashWindow::~TSplashWindow()
        {
        if (fSplashPicture)
                DisposeHandle((Handle) fSplashPicture);  // Oops!
        this->Close();
        }

TWindow::Close(void)
        {
        WindowPtr       newFrontWindow = nil;
        if (FrontNonFloatingWindow() == fWindow)
          newFrontWindow = (WindowPtr)((WindowPeek)fWindow)->nextWindow;
        this->Activate(false);
        DisposeWindow(fWindow);
        if (newFrontWindow)
           HiliteAndActivateWindow(newFrontWindow,true);
        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
gpowell@mv.us.adobe.com

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
mark_tillinghast@lamg.com

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)
#else
#define ReportError(err)  /* nothing */
#endif

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

FileMaker Pro 19.4.2 - Quickly build cus...
FileMaker Pro is the tool you use to create a custom app. You also use FileMaker Pro to access your app on a computer. Start by importing data from a spreadsheet or using a built-in Starter app to... Read more
Adobe Illustrator 26.0.3 - Professional...
You can download Adobe Illustrator for Mac as a part of Creative Cloud for only $20.99/month. Adobe Illustrator for Mac is the vector graphics classics in the design industry. It is a digital... Read more
WhatRoute 2.4.9 - Geographically trace o...
WhatRoute is designed to find the names of all the routers an IP packet passes through on its way from your Mac to a destination host. It also measures the round-trip time from your Mac to the router... Read more
Notion 2.0.20 - A unified workspace for...
Notion is the unified workspace for modern teams. Notion Features: Integration with Slack Documents Wikis Tasks Release notes were unavailable when this listing was updated. Download Now]]> Read more
Monterey Cache Cleaner 17.0.2 - Clear ca...
Monterey Cache Cleaner is an award-winning general-purpose tool for macOS X. MCC makes system maintenance simple with an easy point-and-click interface to many macOS X functions. Novice and expert... Read more
Firetask Pro 4.6.8 - Innovative task man...
Firetask Pro represents the next generation of easy-to-use, project-oriented task management apps. By combining David Allen's powerful Getting Things Done (GTD®) approach with classical task... Read more
Smultron 13.0.4 - Easy-to-use, powerful...
Smultron 13 is the text editor for all of us. Smultron is powerful and confident without being complicated. Its elegance and simplicity helps everyone being creative and to write and edit all sorts... Read more
Box Sync 4.0.8057 - Online synchronizati...
Box Sync gives you a hard-drive in the Cloud for online storage. Note: You must first sign up to use Box. What if the files you need are on your laptop -- but you're on the road with your iPhone? No... Read more
Audio Hijack 3.8.10 - Record and enhance...
Audio Hijack (was Audio Hijack Pro) drastically changes the way you use audio on your computer, giving you the freedom to listen to audio when you want and how you want. Record and enhance any audio... Read more
Direct Mail 6.0.1 - Create and send grea...
Direct Mail is an easy-to-use, fully-featured email marketing app purpose-built for macOS. Create, send, and track great looking email campaigns that get results. Start your newsletter by selecting... Read more

Latest Forum Discussions

See All

Hopefully Not Jared’s Last Show – The To...
My suspicions from last week were correct, and after my two kids tested positive for Covid last week both my wife and I have now tested positive as well. It seems you just can’t escape this stuff lately. Thankfully the two little ones are pretty... | Read more »
TouchArcade Game of the Week: ‘Micro RPG...
I feel like idle games are one of those perfect fits for the mobile platform. Not that they replace more involved gaming experiences when you’re in the mood for that, but they do fit in alongside other types of games just fine as a “go to" when you... | Read more »
‘Phantom Blade: Executioners’ Closed Bet...
Phantom Blade: Executioners is holding a small-scale technical test that lets players get first dibs on the KungFuPunk action RPG. Offered to selected players only, S-Game’s first Closed Beta Test will provide players with limited edition in-game... | Read more »
New ‘Warhammer 40,000: Tacticus’ Video S...
Back in September Snowprint Studios, who you may know from their previous Legend of Solgard or Rivengard, announced that they’d partnered up with Games Workshop to put out a new tactical game in the Warhammer 40,000 universe titled Warhammer 40,000... | Read more »
SwitchArcade Round-Up: ‘Pokemon Legends:...
Hello gentle readers, and welcome to the SwitchArcade Round-Up for January 28th, 2022. We’ve got a bunch of new releases to look at today, with a few big hitters, a few mid-level diversions, and a healthy supply of compost. Since it’s Friday, we... | Read more »
Phantom Blade: Executioners, S-Game...
S-Game has kicked off its first Closed Beta Test for Phantom Blade: Executioners, inviting a selected few to get first dibs on the upcoming KungFuPunk action RPG on mobile. The CBT officially begins this January 28th, and beta testers will receive... | Read more »
‘Infinite Galaxy’ First Anniversary: Cel...
Cultivating a new generation of valiant commanders across 240 countries worldwide, Infinite Galaxy has quenched players’ thirst to explore the vastness of space – and there are only more intergalactic adventures to embark on from here on out. Camel... | Read more »
War and Order: How to brave the cold in...
War and Order's 6th-anniversary celebrations are underway, and all in good time too - this season not only brings about fabulous festivities, but it also lets players experience the harsh winter in an entirely new way. [Read more] | Read more »
‘Hidden Folks+’ Is This Week’s New Apple...
The original Hidden Folks from Adriaan de Jongh is an excellent hidden objects game featuring hand drawn visuals. It is an absolute joy to play, and it has now released on Apple Arcade in the form of Hidden Folks+ () as an App Store great. If you’... | Read more »
Mini Metro’s First Big Update of 2022 Ad...
Last year saw great updates for Dinosaur Polo Club’s Mini Metro ($3.99) which is also available on Apple Arcade as an App Store Great. | Read more »

Price Scanner via MacPrices.net

Apple has clearance 2020 13″ MacBook Airs ava...
Apple has clearance, Certified Refurbished, 2020 13″ Intel-based MacBook Airs in stock today starting at only $719 and up to $370 off original MSRP. Each MacBook features a new outer case, comes with... Read more
The cheapest iPhones for sale today at Apple...
Apple has restocked Apple Certified Refurbished iPhone 8 models starting at only $359. Each refurbished iPhone comes with a fresh external case, standard Apple 1-year warranty, and free shipping.... Read more
14″ MacBook Pro with Apple M1 Max CPU now in...
Looking for a new 14″ MacBook Pro with an Apple M1 Max CPU? Stock is finally trickling into Apple resellers. B&H has Silver 14″ M1 Max MacBook Pros in stock today for $2899 including free 1-2 day... Read more
14″ MacBook Pros with Apple M1 Pro CPUs are i...
Amazon is reporting stock of 14″ MacBook Pros with M1 Pro CPUs today with a $50 discount. Shipping is free, and delivery is available by February 1st for most configurations. Be sure to make your... Read more
Apple has restocked 13″ M1 MacBook Pros for $...
Apple has restocked a full line of 13″ M1 MacBook Pros available Certified Refurbished, starting at only $1099 and up to $230 off original MSRP. These are the cheapest M1 MacBook Pros for sale today... Read more
Apple’s AirPods Max headphones are on sale fo...
Amazon has Silver, Blue, and Space Gray Apple AirPods Max headphones on sale today for $100 off MSRP. Shipping is free, and all models are in stock today. Their price is the lowest currently... Read more
Open a new line of service at Verizon and get...
Verizon is giving away 64GB Apple iPhone 12 minis or your choice of an iPhone 11 to customers who choose one of these phones and open a new line of service. Offer is available online only, and no... Read more
Open-box 13″ M1 MacBook Airs now available st...
QuickShip Electronics has open-box return 13″ M1 MacBook Airs in stock and on sale for $200-$400 off MSRP on their eBay store right now with free express delivery. According to QuickShip, “The item... Read more
Verizon’s 2022 iPad promo: $100-$310 off any...
Verizon has cellular-capable iPads on sale for $100-$310 off MSRP when purchased with an Unlimited service plan. Sale price is applied to your account monthly over a 24 or 30 month period, depending... Read more
Sunday Sale: Apple AirPods are on sale for up...
Amazon has Apple AirPods on sale for $10-$100 off MSRP today, depending on the model. All are in stock today with free delivery: – AirPods Max headphones (Blue): $449 $100 off MSRP – AirPods Max... Read more

Jobs Board

Registered Nurse (RN) Employee Health PSJH -...
…is calling for a Registered Nurse (RN) Employee Health PSJH to our location in Apple Valley, CA.** We are seeking a Registered Nurse (RN) Employee Health PSJH to be Read more
Systems Administrator - Pearson (United State...
…and troubleshoot Windows operating systems (workstation and server), laptop computers, Apple iPads, Chromebooks and printers** + **Administer and troubleshoot all Read more
IT Assistant Level 1- IT Desktop Support Anal...
…providing tier-1 or better IT help desk support in a large Windows and Apple environment * Experience using IT Service Desk Management Software * Knowledge of IT Read more
Human Resources Business Partner PSJH - Provi...
…**is calling a** **Human Resources Business Partner, PSJH** **to our location in Apple Valley, CA.** **Applicants that meet qualifications will receive a text with Read more
Manager Community Health Investment Programs...
…is calling a Manager Community Health Investment Programs PSJH to our location in Apple Valley, CA.** **Qualified candidates will be invited to do a self-paced video Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.