[comp.windows.interviews] GetCanvas returns NULL

linton@marktwain.rad.sgi.com (Mark Linton) (05/13/91)

In article <9105120300.AA29103@shiva.trl.OZ.AU>, s.michnowicz@trl.oz.au (Simon Michnowicz - A Free Spirit) writes:
|> I have an application, which consists uses a painter to
|> display text.
|> 
|> i.e.
|> Redraw()
|>   {
|>   C=GetCanvas()
|>   P= new Painter;
|>   P->Text(...)
|>   }
|> 
|> THis works when I raise and lower the window.  I print
|> out the value of the pointers generated.
|> However when I call redraw explicitely, to update the
|> screen,  GetCanvas() returns a null pointer , and the
|> program crashes.

Please explain in what context you are calling redraw explicitly.
If you call redraw when the window is unmapped, for example,
the canvas will be nil.

doron@mobydick.leis.bellcore.com (Doron Shalmon) (05/14/91)

In article <1991May13.161932.28060@fido.wpd.sgi.com> you write:
|> Please explain in what context you are calling redraw explicitly.
|> If you call redraw when the window is unmapped, for example,
|> the canvas will be nil.

Is there some point in the life of an interactor when it is guaranteed
to be mapped?  What I'm looking for is some member function in which
I can be guaranteed that the canvas is not nil (much the same way as
you *know* that the interactor knows about its parents and the world
in Reconfig).

Specifically, I have a damage object that needs to know the canvas
of a graphic block, and I'd like to have the graphic block take care
of this when it gets mapped (rather than do some explicit Set call
after I insert the graphic block into the world).

Thanks.

===========================================================================
                               Doron Shalmon
           Bellcore -- Network Planning and Distribution Systems
                  Internet:  doron@yogi.leis.bellcore.com
                      UUCP:  ...!bellcore!yogi!doron

    "All opinions expressed are mine, and do not necessarily represent
      those of my employer, Bell Communications Research (Bellcore)"

linton@marktwain.rad.sgi.com (Mark Linton) (05/15/91)

In article <1991May14.052613.29659@bellcore.bellcore.com>, doron@mobydick.leis.bellcore.com (Doron Shalmon) writes:
|> Is there some point in the life of an interactor when it is guaranteed
|> to be mapped?  What I'm looking for is some member function in which
|> I can be guaranteed that the canvas is not nil (much the same way as
|> you *know* that the interactor knows about its parents and the world
|> in Reconfig).
|> 
|> Specifically, I have a damage object that needs to know the canvas
|> of a graphic block, and I'd like to have the graphic block take care
|> of this when it gets mapped (rather than do some explicit Set call
|> after I insert the graphic block into the world).

Resize is called when an interactor has a canvas.  However, there
is no corresponding call when a canvas is unmapped or removed.
Your damage object is therefore better off with a pointer to the graphic block and
calling GetCanvas on it.