[haiku-commits] Re: haiku: hrev44673 - src/kits/tracker

  • From: "Ingo Weinhold" <ingo_weinhold@xxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Wed, 03 Oct 2012 15:26:18 +0200

kallisti5 wrote:
> On 2012-10-02 3:59 pm, JÃrÃme Duval wrote:
> > 2012/10/2 <kallisti5@xxxxxxxxxxx>:
> >> hrev44673 adds 1 changeset to branch 'master'
> >> old head: 9af3b8357592d97fbe2b01f6f0cbee8d4eade538
> >> new head: ff09527e4f6f674c4df23e39b365b84e87bfac43
> >>
> >> 
> >> ----------------------------------------------------------------------------
> >>
> >> ff09527: Tracker: Introduce "Restart Deskbar" option (+alpha3)
> >> + BMenuItem* item;
> >> +
> >> + BRoster roster;
> >> + if (!roster.IsRunning(kDeskbarSignature)) {
> >> + item = new BMenuItem(B_TRANSLATE("Restart Deskbar"),
> >> + new BMessage(kRestartDeskbar));
> >> + menu->AddItem(item);
> >> + menu->AddSeparatorItem();
> >> + }
> >> +
> >
> > IMO the variable declaration should happen where it is used first.
> 
> Except variable scope says I can't do it in the if statement as 'item' 
> is also used later in the code :)

Sure you can. Just also revert the second hunk of that change. Since the second 
"item" has nothing to do with the first, there's nothing that forces you to use 
the same variable.

CU, Ingo

Other related posts: