Skip to content

Commit

Permalink
booru/page: Prevent exception when saving image(s)
Browse files Browse the repository at this point in the history
Standard threads need join to be called before they are destructed.
  • Loading branch information
ahodesuka committed Nov 24, 2017
1 parent 3fdd157 commit 915f11c
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/booru/page.cc
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ void Page::search(const std::shared_ptr<Site> &site)
void Page::save_image(const std::string &path, const std::shared_ptr<Image> &img)
{
m_SaveCancel->reset();
if (m_SaveImagesThread.joinable())
m_SaveImagesThread.join();

m_Saving = true;
m_SaveImagesThread = std::thread([ this, path, img ]()
Expand All @@ -171,6 +173,8 @@ void Page::save_image(const std::string &path, const std::shared_ptr<Image> &img
void Page::save_images(const std::string &path)
{
m_SaveCancel->reset();
if (m_SaveImagesThread.joinable())
m_SaveImagesThread.join();

m_Saving = true;
m_SaveImagesCurrent = 0;
Expand Down

0 comments on commit 915f11c

Please sign in to comment.