diff options
author | Vojtech Kral <vojtech@kral.hk> | 2018-06-05 12:55:23 +0300 |
---|---|---|
committer | bubnikv <bubnikv@gmail.com> | 2018-06-19 19:46:37 +0300 |
commit | 5414f7379d9ba0592f60a37a0c610a569787456c (patch) | |
tree | 4be67d64dd0486c85724fdf53fac0f288fc2fcce /xs/src/avrdude/avrdude-slic3r.cpp | |
parent | 2a07f3a0d58fc5785652bc3deee5e742dac16f05 (diff) |
FirmwareDialog: Fix progress display
Diffstat (limited to 'xs/src/avrdude/avrdude-slic3r.cpp')
-rw-r--r-- | xs/src/avrdude/avrdude-slic3r.cpp | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/xs/src/avrdude/avrdude-slic3r.cpp b/xs/src/avrdude/avrdude-slic3r.cpp index a859200fb..cf4380fdb 100644 --- a/xs/src/avrdude/avrdude-slic3r.cpp +++ b/xs/src/avrdude/avrdude-slic3r.cpp @@ -34,6 +34,7 @@ struct AvrDude::priv { std::string sys_config; std::vector<std::string> args; + RunFn run_fn; MessageFn message_fn; ProgressFn progress_fn; CompleteFn complete_fn; @@ -94,6 +95,12 @@ AvrDude& AvrDude::args(std::vector<std::string> args) return *this; } +AvrDude& AvrDude::on_run(RunFn fn) +{ + if (p) { p->run_fn = std::move(fn); } + return *this; +} + AvrDude& AvrDude::on_message(MessageFn fn) { if (p) { p->message_fn = std::move(fn); } @@ -123,11 +130,17 @@ AvrDude::Ptr AvrDude::run() if (self->p) { auto avrdude_thread = std::thread([self]() { - auto res = self->p->run(); - if (self->p->complete_fn) { - self->p->complete_fn(res); - } - }); + if (self->p->run_fn) { + self->p->run_fn(); + } + + auto res = self->p->run(); + + if (self->p->complete_fn) { + self->p->complete_fn(res); + } + }); + self->p->avrdude_thread = std::move(avrdude_thread); } |