[vlc-devel] [PATCH] qt: fix missing return value in ChapterModel

Hugo Beauzée-Luyssen hugo at beauzee.fr
Fri Jun 14 17:33:10 CEST 2019


On Fri, Jun 14, 2019, at 5:30 PM, Hugo Beauzée-Luyssen wrote:
> On Fri, Jun 14, 2019, at 5:27 PM, Abel Tesfaye wrote:
> > From: Abel Tesfaye <Abeltesfaye45 at gmail.com>
> > 
> > ---
> >  modules/gui/qt/util/input_models.cpp | 23 ++++++++++++-----------
> >  1 file changed, 12 insertions(+), 11 deletions(-)
> > 
> > diff --git a/modules/gui/qt/util/input_models.cpp 
> > b/modules/gui/qt/util/input_models.cpp
> > index 918f93193d..6b0a0b8bf1 100644
> > --- a/modules/gui/qt/util/input_models.cpp
> > +++ b/modules/gui/qt/util/input_models.cpp
> > @@ -346,24 +346,25 @@ void ChapterListModel::resetTitle(const 
> > vlc_player_title *newTitle)
> >  
> >  QString ChapterListModel::getNameAtPosition(float pos) const
> >  {
> > -    if(m_title == nullptr)
> > -        return qtr("nothing found");
> > +    if(m_title != nullptr){
> >  
> > -    vlc_tick_t posTime = pos * m_title->length;
> > -    int prevChapterIndex = 0;
> > +        vlc_tick_t posTime = pos * m_title->length;
> > +        int prevChapterIndex = 0;
> >  
> > -    for(unsigned int i=0;i<m_title->chapter_count;i++){
> > +        for(unsigned int i=0;i<m_title->chapter_count;i++){
> >  
> > -        vlc_tick_t currentChapterTime = m_title->chapters[i].time;
> > +            vlc_tick_t currentChapterTime = m_title->chapters[i].time;
> >  
> > -        if(currentChapterTime > posTime)
> > -           return qfu(m_title->chapters[prevChapterIndex].name);
> > +            if(currentChapterTime > posTime)
> > +                return qfu(m_title->chapters[prevChapterIndex].name);
> >  
> > -        else if(i == (m_title->chapter_count - 1))
> > -            return qfu(m_title->chapters[i].name);
> > +            else if(i == (m_title->chapter_count - 1))
> > +                return qfu(m_title->chapters[i].name);
> >  
> > -        prevChapterIndex = i;
> > +            prevChapterIndex = i;
> > +        }
> >      }
> > +    return QString();
> >  }
> >  
> >  //***************************
> 
> Hi,
> 
> Could you split the patch in 2, one for the actual change, and one for 
> the indentation fix? That eases up reading tge change quite a lot :)
> 

That being said, in this specific case, wouldn't it be simpler to just add a return QString{} at the bottom of the function? (I'm not entirely sure we need a translatable string for that error)

-- 
  Hugo Beauzée-Luyssen
  hugo at beauzee.fr


More information about the vlc-devel mailing list