[poppler] qt5/src

Albert Astals Cid aacid at kde.org
Wed Jan 10 21:42:39 UTC 2018


El dimecres, 10 de gener de 2018, a les 20:39:22 CET, Adam Reichold va 
escriure:
> Hello again,
> 
> If you mind the smart pointer templates, then what about
> 
> auto* const newData = new PageTransitionData(*other.data);
> auto* const oldData = data;
> data = newData;
> delete oldData;
> 
> As this is a library which does not know what kind of programs will make
> use of it, exception safety is quite important IMHO.

Honestly poppler is full of things more important than this operator (that is 
unused by anyone since it would be crashing if someone had been using it :D) 
that would have problems like this, if you have memory problems that can't 
have this new done, something else will fail for sure.

Cheers,
  Albert

> 
> Best regards, Adam.
> 
> Am 10.01.2018 um 19:57 schrieb Albert Astals Cid:
> > El dimecres, 10 de gener de 2018, a les 8:57:05 CET, Adam Reichold va
> > 
> > escriure:
> >> Hello,
> >> 
> >> Am 09.01.2018 um 23:41 schrieb Albert Astals Cid:
> >>> +PageTransition& PageTransition::operator=(const PageTransition &other)
> >>> +{
> >>> +  if ( this != &other ) {
> >>> +    delete data;
> >>> +    data = new PageTransitionData(*other.data);
> >>> +  }
> >>> +
> >>> +  return *this;
> >>> +}
> >>> +
> >> 
> >> In view of exception safety, I think it would be better to first create
> >> the new data and then destroy the old one, i.e.:
> >> 
> >> std::unique_ptr<PageTransitionData> newData{new
> >> PageTransitionData(*other.data)};
> >> data.swap(newData);
> > 
> > I'd really much prefer code i can read over safety exception :D
> > 
> > Cheers,
> > 
> >   Albert
> >> 
> >> (assuming PageTransition::data becomes a unique_ptr)
> >> 
> >> Regards, Adam.
> >> _______________________________________________
> >> poppler mailing list
> >> poppler at lists.freedesktop.org
> >> https://lists.freedesktop.org/mailman/listinfo/poppler
> > 
> > _______________________________________________
> > poppler mailing list
> > poppler at lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/poppler
> 
> _______________________________________________
> poppler mailing list
> poppler at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/poppler




More information about the poppler mailing list