diff options
author | Vojtech Kral <vojtech@kral.hk> | 2018-07-24 18:42:12 +0300 |
---|---|---|
committer | bubnikv <bubnikv@gmail.com> | 2018-07-27 14:27:52 +0300 |
commit | a32bd17b752317450e35c398b61356cdbe13998d (patch) | |
tree | ee589896b5b849c5ab2596c78a9af6200bef4ca5 /xs/src/avrdude/avrdude-slic3r.cpp | |
parent | a7eaf38853c1c804c4f4c7d5e30801f196713727 (diff) |
FirmwareUpdater: MMU 2.0 / Caterina flashing
Diffstat (limited to 'xs/src/avrdude/avrdude-slic3r.cpp')
-rw-r--r-- | xs/src/avrdude/avrdude-slic3r.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/xs/src/avrdude/avrdude-slic3r.cpp b/xs/src/avrdude/avrdude-slic3r.cpp index 030353413..4a7f22d6e 100644 --- a/xs/src/avrdude/avrdude-slic3r.cpp +++ b/xs/src/avrdude/avrdude-slic3r.cpp @@ -36,6 +36,7 @@ struct AvrDude::priv std::string sys_config; std::deque<std::vector<std::string>> args; size_t current_args_set = 0; + bool cancelled = false; RunFn run_fn; MessageFn message_fn; ProgressFn progress_fn; @@ -141,11 +142,16 @@ AvrDude::Ptr AvrDude::run() if (self->p) { auto avrdude_thread = std::thread([self]() { + bool cancel = false; + int res = -1; + if (self->p->run_fn) { - self->p->run_fn(); + self->p->run_fn(*self); } - auto res = self->p->run(); + if (! self->p->cancelled) { + res = self->p->run(); + } if (self->p->complete_fn) { self->p->complete_fn(res, self->p->current_args_set); @@ -160,7 +166,10 @@ AvrDude::Ptr AvrDude::run() void AvrDude::cancel() { - ::avrdude_cancel(); + if (p) { + p->cancelled = true; + ::avrdude_cancel(); + } } void AvrDude::join() |