Replace std::variant with boost::variant

Unavailable on MacOS < 1.14
This commit is contained in:
tamasmeszaros 2021-12-02 15:55:57 +01:00
parent e367ef8011
commit 4d0088e72f
2 changed files with 9 additions and 7 deletions

View File

@ -6,10 +6,10 @@ namespace Slic3r { namespace GUI {
void BoostThreadWorker::WorkerMessage::deliver(BoostThreadWorker &runner) void BoostThreadWorker::WorkerMessage::deliver(BoostThreadWorker &runner)
{ {
switch(MsgType(m_data.index())) { switch(MsgType(get_type())) {
case Empty: break; case Empty: break;
case Status: { case Status: {
StatusInfo info = std::get<Status>(m_data); auto info = boost::get<StatusInfo>(m_data);
if (runner.get_pri()) { if (runner.get_pri()) {
runner.get_pri()->set_progress(info.status); runner.get_pri()->set_progress(info.status);
runner.get_pri()->set_status_text(info.msg.c_str()); runner.get_pri()->set_status_text(info.msg.c_str());
@ -17,7 +17,7 @@ void BoostThreadWorker::WorkerMessage::deliver(BoostThreadWorker &runner)
break; break;
} }
case Finalize: { case Finalize: {
JobEntry& entry = std::get<Finalize>(m_data); auto& entry = boost::get<JobEntry>(m_data);
entry.job->finalize(entry.canceled, entry.eptr); entry.job->finalize(entry.canceled, entry.eptr);
// Unhandled exceptions are rethrown without mercy. // Unhandled exceptions are rethrown without mercy.
@ -27,7 +27,7 @@ void BoostThreadWorker::WorkerMessage::deliver(BoostThreadWorker &runner)
break; break;
} }
case MainThreadCall: { case MainThreadCall: {
MainThreadCallData &calldata = std::get<MainThreadCall>(m_data); auto &calldata = boost::get<MainThreadCallData >(m_data);
calldata.fn(); calldata.fn();
calldata.promise.set_value(); calldata.promise.set_value();

View File

@ -1,7 +1,7 @@
#ifndef BOOSTTHREADWORKER_HPP #ifndef BOOSTTHREADWORKER_HPP
#define BOOSTTHREADWORKER_HPP #define BOOSTTHREADWORKER_HPP
#include <variant> #include <boost/variant.hpp>
#include "Worker.hpp" #include "Worker.hpp"
@ -40,10 +40,12 @@ class BoostThreadWorker : public Worker, private Job::Ctl
std::promise<void> promise; std::promise<void> promise;
}; };
struct EmptyMessage {};
class WorkerMessage class WorkerMessage
{ {
enum MsgType { Empty, Status, Finalize, MainThreadCall }; enum MsgType { Empty, Status, Finalize, MainThreadCall };
std::variant<std::monostate, StatusInfo, JobEntry, MainThreadCallData> m_data; boost::variant<EmptyMessage, StatusInfo, JobEntry, MainThreadCallData> m_data;
public: public:
WorkerMessage() = default; WorkerMessage() = default;
@ -53,7 +55,7 @@ class BoostThreadWorker : public Worker, private Job::Ctl
WorkerMessage(JobEntry &&entry) : m_data{std::move(entry)} {} WorkerMessage(JobEntry &&entry) : m_data{std::move(entry)} {}
WorkerMessage(MainThreadCallData fn) : m_data{std::move(fn)} {} WorkerMessage(MainThreadCallData fn) : m_data{std::move(fn)} {}
int get_type () const { return m_data.index(); } int get_type () const { return m_data.which(); }
void deliver(BoostThreadWorker &runner); void deliver(BoostThreadWorker &runner);
}; };