🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.next.programmer
Article #1660

Re: Developer Support "core dump": NXImage question (a better answer?)

#1660
From: Paul Burchard
Date: Wed, 30 Sep 1992 00:52
33 lines
2347 bytes
In article <5201@rosie.NeXT.COM> julie@next.com (Julie Zelenski) writes:
> 
> A developer recently asked, 
> 
> "I have encountered difficulty in working with the ButtonCell class and  
> (firmly) believe it may be a bug in NeXT's appkit.
> 
> I have set my ButtonCell to display a certain image using setIcon:.  Later  
> I will change the image and I want to free the original image.  No problem  
> occurs at the time you free the image, but the behavior of the program is  
> unpredictable after that point and it is prone to crashing upon sending  
> the display message to the view containing my ButtonCell.  The backtrace  
> ends with a failed call to objc_msgSend().
>

By chance I was investigating *exactly* this problem today.  I was having this problem despite making sure that this was NOT a shared image with any other part of the program, and further, I had been careful to FIRST change the cell's icon and THEN free the old one (in case -setIcon: somehow needs to "deinstall" the old icon):

    [cell setIcon:newIconName];
    [[NXImage findImageNamed:oldIconName] free]; //!!! still flaky

Nevertheless I still had the problem.  My conclusion was that *somewhere* in the bowels of the AppKit, a pointer to the old icon was still being cached.  So to flush out any display caches I triggered an update before freeing the image:

    [cell setIcon:newIconName]; // cell == self->cell
    [self update]; // make sure image references flushed out of system!
    [[NXImage findImageNamed:oldIconName] free]; // OK!

This now appears to work.

--
--------------------------------------------------------------------
Paul Burchard	<burchard@geom.utah.edu>
``I'm still learning how to count backwards from infinity...''
--------------------------------------------------------------------
Technical Details
Message-ID: <1992Sep30.005207.27610@news2.cis.umn.edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!caen!spool.mu.edu!umn.edu!news
References: <5201@rosie.NeXT.COM>

Show Full Headers
Complete Article Headers
Newsgroups: comp.sys.next.programmer
Path: arc1-ca.pugleaf.net!sparky!uunet!caen!spool.mu.edu!umn.edu!news
From: burchard@horizon.math.utah.edu (Paul Burchard)
Subject: Re: Developer Support "core dump":  NXImage question (a better answer?)
Message-ID: <1992Sep30.005207.27610@news2.cis.umn.edu>
Sender: news@news2.cis.umn.edu (Usenet News Administration)
Nntp-Posting-Host: dialup-slip-1-28.gw.umn.edu
Organization: University of Minnesota
References: <5201@rosie.NeXT.COM>
Date: Wed, 30 Sep 1992 00:52:07 GMT
Lines: 33