Skip to content

Commit

Permalink
Workaround for MSVC2013's buggy atomic
Browse files Browse the repository at this point in the history
  • Loading branch information
CelticMinstrel committed Apr 2, 2016
1 parent fe818f8 commit bfc6744
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
14 changes: 12 additions & 2 deletions src/gui/dialogs/loadscreen.cpp
Expand Up @@ -115,7 +115,12 @@ void tloadscreen::progress(const char* stage)
return;
}
if(stage) {
current_load->current_stage_.store(stage, std::memory_order_release);
current_load->current_stage_
#if defined(_MSC_VER) && _MSC_VER < 1900
= stage;
#else
.store(stage, std::memory_order_release);
#endif
}
}

Expand All @@ -126,7 +131,12 @@ void tloadscreen::timer_callback(twindow& window)
if (!worker_ || worker_->timed_join(boost::posix_time::milliseconds(0))) {
window.close();
}
const char* stage = current_stage_.load(std::memory_order_acquire);
const char* stage = current_stage_
#if defined(_MSC_VER) && _MSC_VER < 1900
;
#else
.load(std::memory_order_acquire);
#endif
if (stage && (current_visible_stage_ == stages.end() || stage != current_visible_stage_->first))
{
auto iter = stages.find(stage);
Expand Down
7 changes: 6 additions & 1 deletion src/gui/dialogs/loadscreen.hpp
Expand Up @@ -51,7 +51,7 @@ class tloadscreen : public tdialog
/**
* Hides the window.
*
* The hiding also destroys the window. It is save to call the function
* The hiding also destroys the window. It is safe to call the function
* when the window is not shown.
*/
void close();
Expand Down Expand Up @@ -79,7 +79,12 @@ class tloadscreen : public tdialog
tlabel* animation_label_;
static tloadscreen* current_load;

#if defined(_MSC_VER) && _MSC_VER < 1900
// std::atomic is buggy in MSVC 2013 - doesn't work for cv types
const char* current_stage_;
#else
std::atomic<const char*> current_stage_;
#endif
std::map<std::string,std::string>::const_iterator current_visible_stage_;
};

Expand Down

0 comments on commit bfc6744

Please sign in to comment.