[CinCV TNG] [PATCH] Remove else condition that is never accessed in mwindowgui.C

Nicola Ferralis feranick at hotmail.com
Sun Apr 12 22:50:31 CEST 2015


This patch is dropped for now, until I can revisit it based on the feedback below.

Thanks,
Nicola

> Date: Sun, 1 Mar 2015 10:34:29 +0100
> From: j6t at kdbg.org
> To: cinelerra at lists.cinelerra-cv.org
> Subject: Re: [CinCV TNG] [PATCH] Remove else condition that is never accessed in mwindowgui.C
> 
> Am 28.02.2015 um 22:43 schrieb Nicola Ferralis:
> > Date: Sat, 28 Feb 2015 14:35:53 -0500
> > Subject: [PATCH] Remove else condition that is never accessed in mwindowgui.C
> >
> > The variables need_xscroll and need_yscroll in
> > MWindowGUI::get_scrollbars() are set as 1. A subsequent if
> > statement checks if they are 1 (which is always true) and has a
> > else statement for when they are not 1 that is unaccessible,
> > leading to dead code.
> 
> Yes, but:
> 
> 1. Why are you not removing the variables as well? Aren't they now dead 
> code as well?
> 
> 2. There is a lot of code that is commented out, where need_?scroll were 
> used. You should remove that, too.
> 
> And when you do the latter, you should understand why that code was 
> commented out and argue why we would never want to have it back.
> 
> > This patch removes the if condition
> > assuming that is always true.
> > ---
> >   cinelerra/mwindowgui.C | 52 +++++++++++++++++---------------------------------
> >   1 file changed, 17 insertions(+), 35 deletions(-)
> >
> > diff --git a/cinelerra/mwindowgui.C b/cinelerra/mwindowgui.C
> > index caf99fc..fcb5f50 100644
> > --- a/cinelerra/mwindowgui.C
> > +++ b/cinelerra/mwindowgui.C
> > @@ -138,38 +138,27 @@ void MWindowGUI::get_scrollbars()
> >   	}
> >   //printf("MWindowGUI::get_scrollbars 1\n");
> >
> > -	if(need_xscroll)
> > -	{
> > -		if(!samplescroll)
> > -			add_subwindow(samplescroll = new SampleScroll(mwindow,
> > -				this,
> > -				mwindow->theme->mhscroll_x,
> > -				mwindow->theme->mhscroll_y,
> > -				mwindow->theme->mhscroll_w));
> > -		else
> > -			samplescroll->resize_event();
> > -
> > -		samplescroll->set_position();
> > -	}
> > +	if(!samplescroll)
> > +		add_subwindow(samplescroll = new SampleScroll(mwindow,
> > +			this,
> > +			mwindow->theme->mhscroll_x,
> > +			mwindow->theme->mhscroll_y,
> > +			mwindow->theme->mhscroll_w));
> >   	else
> > -	{
> > -		if(samplescroll) delete samplescroll;
> > -		samplescroll = 0;
> > -		mwindow->edl->local_session->view_start = 0;
> > -	}
> > +		samplescroll->resize_event();
> > +
> > +	samplescroll->set_position();
> >   //printf("MWindowGUI::get_scrollbars 1\n");
> >
> > -	if(need_yscroll)
> > -	{
> >   //printf("MWindowGUI::get_scrollbars 1.1 %p %p\n", this, canvas);
> > -		if(!trackscroll)
> > -			add_subwindow(trackscroll = new TrackScroll(mwindow,
> > -				this,
> > -				mwindow->theme->mvscroll_x,
> > -				mwindow->theme->mvscroll_y,
> > -				mwindow->theme->mvscroll_h));
> > -		else
> > -			trackscroll->resize_event();
> > +	if(!trackscroll)
> > +		add_subwindow(trackscroll = new TrackScroll(mwindow,
> > +			this,
> > +			mwindow->theme->mvscroll_x,
> > +			mwindow->theme->mvscroll_y,
> > +			mwindow->theme->mvscroll_h));
> > +	else
> > +		trackscroll->resize_event();
> >
> >
> >   //printf("MWindowGUI::get_scrollbars 1.2\n");
> > @@ -177,13 +166,6 @@ void MWindowGUI::get_scrollbars()
> >   			mwindow->edl->local_session->track_start,
> >   			view_h);
> >   //printf("MWindowGUI::get_scrollbars 1.3\n");
> > -	}
> > -	else
> > -	{
> > -		if(trackscroll) delete trackscroll;
> > -		trackscroll = 0;
> > -		mwindow->edl->local_session->track_start = 0;
> > -	}
> >   //printf("get_scrollbars 2 %d %d\n", need_xscroll, w_needed);
> >   }
> >
> > -- 1.9.3 (Apple Git-50)
> 
> _______________________________________________
> Cinelerra mailing list
> Cinelerra at lists.cinelerra-cv.org
> http://lists.cinelerra-cv.org/cgi-bin/mailman/listinfo/cinelerra
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cinelerra-cv.org/pipermail/cinelerra/attachments/20150412/d80da1ad/attachment.html>


More information about the Cinelerra mailing list