[Lumiera] TimelineZoomScale Question About Pointers

Michael Fisher mfisher31 at gmail.com
Sat Oct 8 23:15:05 CEST 2011


Hello All,

I'm working on improving the recently created ZoomScale widget in the
timline.  this might seem odd but I'm trying to figure out why my code is
'working' as opposed to 'not working'.  I fiddled with *'s and &'s until it
would build and run without a crash.  here's what I have.  Trying to get a
reference from TimelineViewWindow into TimelineZoomScale

timeline-zoom-scale.hpp

added a.. TimelineViewWindow *timelineViewWindow

used in timeline-zoom-scale.cpp as

void
TimelineZoomScale::set_view_window(TimelineViewWindow& view_window)
{
  // Check if view_window is valid here...
  timelineViewWindow = & view_window;
}

Gets called from timeline-panel.cpp  as

zoomScale.set_view_window(timelineWidget->get_state()->get_view_window());

It works fine (i think), I just don't understand why.  since i'm passing in
TimelineViewWindow& view_window, why doesn't it work with timelineViewWindow
= view_window (without the &)?  Why does it need to "take the reference of"
a variable that is already a reference?  I just don't get that.

Sorry for being such a pointer's newbie.  I just really, REALLY, want to
understand them and how to work with them so I can effectively contribute to
Lumiera.  You know, instead of just winging it and changing characters until
it works (kind of a waste of time really).

Anyway, I appreciate everyone's help here.  I really do pick up quickly and
once I can get a grip on pointers, you'll see more frequent patches from
me.

I don't like to mess with code that I don't understand. ;)

Also, how do I know when to use  ->'s instead of .'s  .  Again, If one
doesn't work, I try the other.  I'd much rather know what the heck I'm doing
instead of winging it.  What's really confusing though to me is some objects
are using both.  Totally weird to me.

pz
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lumiera.org/pipermail/lumiera/attachments/20111008/38688673/attachment.html>


More information about the Lumiera mailing list