Fix memory leak

There is no delete for TextFormat objects in PageDisplay destructor.
This commit is contained in:
elsid 2018-03-10 22:18:47 +03:00
parent 27610a85ac
commit a26483ab26

View file

@ -892,7 +892,7 @@ protected:
public: public:
typedef TypesetBookImpl::StyleImpl Style; typedef TypesetBookImpl::StyleImpl Style;
typedef std::map <TextFormat::Id, TextFormat*> ActiveTextFormats; typedef std::map <TextFormat::Id, std::unique_ptr<TextFormat>> ActiveTextFormats;
int mViewTop; int mViewTop;
int mViewBottom; int mViewBottom;
@ -1048,7 +1048,7 @@ public:
{ {
if (mNode != NULL) if (mNode != NULL)
i->second->destroyDrawItem (mNode); i->second->destroyDrawItem (mNode);
delete i->second; i->second.reset();
} }
mActiveTextFormats.clear (); mActiveTextFormats.clear ();
@ -1115,11 +1115,11 @@ public:
if (j == this_->mActiveTextFormats.end ()) if (j == this_->mActiveTextFormats.end ())
{ {
TextFormat * textFormat = new TextFormat (Font, this_); std::unique_ptr<TextFormat> textFormat(new TextFormat (Font, this_));
textFormat->mTexture = Font->getTextureFont (); textFormat->mTexture = Font->getTextureFont ();
j = this_->mActiveTextFormats.insert (std::make_pair (Font, textFormat)).first; j = this_->mActiveTextFormats.insert (std::make_pair (Font, std::move(textFormat))).first;
} }
j->second->mCountVertex += run.mPrintableChars * 6; j->second->mCountVertex += run.mPrintableChars * 6;