gettingstarted
[Top] [All Lists]

Re: [RB List] NilObjectException?

To: Getting Started <gettingstarted at lists dot realsoftware dot com>
Subject: Re: [RB List] NilObjectException?
From: Eirik Karlsen <eikarlse at online dot no>
Date: Tue, 22 Feb 2005 22:15:03 +0100
Delivered-to: gettingstarted at lists dot realsoftware dot com
References: <001801c50fb9$7ff00550$0100a8c0 at bremerb7sqedlr> <a06200748be3186f28bcf at [10 dot 10 dot 13 dot 4]> <4216572D dot DBCDB2F8 at online dot no> <3708cc77eab40f3102460488f5ebfefd at freaksw dot com> <ec5c706d70d8101ee4acb0fabf69ce11 at shaw dot ca> <42166592 dot 389BF02 at online dot no> <a06200718be3c205210c7 at [10 dot 10 dot 13 dot 4]> <4218648E dot 2394C438 at online dot no> <a06200703be3e64982cef at [10 dot 10 dot 13 dot 4]> <4218ED5B dot 25A3B7AD at online dot no> <a06200708be3eb033e601 at [10 dot 10 dot 13 dot 4]> <421B9684 dot 4DFC1551 at online dot no> <4cf15d148b5ce7dade9147c08246181d at mobleybros dot com>
Yes but that doesn't help much if the picture is created in one method /
event,
and the picture's content is created in another method (or methods),
which is the case in my program.

Before we turn this into another lengthy thread
I will now strip down the program until I find the cause of this mischief.


Phil M wrote:

> On Feb 22, 2005, at 12:31 PM, Eirik Karlsen wrote:
>
> > In the window's Open event a new picture is defined like this,
> > GraphFront=newPicture(CanvasGraph.width,CanvasGraph.height,8),
> > and the variable is given a Public scope in the window's Properties,
> > and in a method I try to access it by either
> > GraphFront.graphics.DrawPicture GraphFront,0,0 or
> > s=GraphFront.graphics
>
> It is always a good idea to check for Nil before you try to access
> something like this.  In fact, when I want to invalidate a picture I
> usually set it to Nil so that it would be created from scratch.  For
> example, this is similar to what I have in my Paint event for my Canvas
> so that double-buffering works.
>
>    If GraphFront Is Nil Then
>      RenderGraphFront()    // contains the code to create GraphFront
>    End If
>
>    g.DrawPicture(GraphFront, 0, 0)
>
> Although technically I can still get a NilObjectException if there is
> not enough memory to create the GraphFront picture.  This *should* only
> be an issue on OS 9:
>
>    GraphFront = NewPicture(w, h, 32)   // NewPicture returns Nil if not
> enough memory.
>
> ______

--
*******************************************
VISIT MY HOME PAGE:
<http://home.online.no/~eikarlse/index.htm>
LAST UPDATED: 23/08/2003
*******************************************
Regards
Eirik Karlsen


_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://www.realsoftware.com/listarchives/lists.html>

<Prev in Thread] Current Thread [Next in Thread>