mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-14 13:45:59 +08:00
Flush stdout when sending progress/warnings in CLI mode
This commit is contained in:
parent
ac2ef88200
commit
8c7014cc3c
@ -644,8 +644,10 @@ int CLI::run(int argc, char **argv)
|
||||
sla_print.set_status_callback(
|
||||
[](const PrintBase::SlicingStatus& s)
|
||||
{
|
||||
if(s.percent >= 0) // FIXME: is this sufficient?
|
||||
if(s.percent >= 0) { // FIXME: is this sufficient?
|
||||
printf("%3d%s %s\n", s.percent, "% =>", s.text.c_str());
|
||||
std::fflush(stdout);
|
||||
}
|
||||
});
|
||||
|
||||
PrintBase *print = (printer_technology == ptFFF) ? static_cast<PrintBase*>(&fff_print) : static_cast<PrintBase*>(&sla_print);
|
||||
|
@ -107,8 +107,10 @@ void PrintBase::status_update_warnings(int step, PrintStateBase::WarningLevel /*
|
||||
auto status = print_object ? SlicingStatus(*print_object, step) : SlicingStatus(*this, step);
|
||||
m_status_callback(status);
|
||||
}
|
||||
else if (! message.empty())
|
||||
else if (! message.empty()) {
|
||||
printf("%s warning: %s\n", print_object ? "print_object" : "print", message.c_str());
|
||||
std::fflush(stdout);
|
||||
}
|
||||
}
|
||||
|
||||
std::mutex& PrintObjectBase::state_mutex(PrintBase *print)
|
||||
|
@ -495,7 +495,7 @@ public:
|
||||
// Calls a registered callback to update the status, or print out the default message.
|
||||
void set_status(int percent, const std::string &message, unsigned int flags = SlicingStatus::DEFAULT) {
|
||||
if (m_status_callback) m_status_callback(SlicingStatus(percent, message, flags));
|
||||
else printf("%d => %s\n", percent, message.c_str());
|
||||
else { printf("%d => %s\n", percent, message.c_str()); std::fflush(stdout); }
|
||||
}
|
||||
|
||||
typedef std::function<void()> cancel_callback_type;
|
||||
|
Loading…
x
Reference in New Issue
Block a user