mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-05-22 12:38:08 +08:00
Merge remote-tracking branch 'remotes/origin/vk-bugfixes'
This commit is contained in:
commit
2b5a1f3e60
@ -105,15 +105,6 @@ sub OnInit {
|
|||||||
|
|
||||||
$self->{preset_updater} = Slic3r::PresetUpdater->new($VERSION_ONLINE_EVENT);
|
$self->{preset_updater} = Slic3r::PresetUpdater->new($VERSION_ONLINE_EVENT);
|
||||||
Slic3r::GUI::set_preset_updater($self->{preset_updater});
|
Slic3r::GUI::set_preset_updater($self->{preset_updater});
|
||||||
eval {
|
|
||||||
if (! $self->{preset_updater}->config_update()) {
|
|
||||||
exit 0;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
if ($@) {
|
|
||||||
warn $@ . "\n";
|
|
||||||
fatal_error(undef, $@);
|
|
||||||
}
|
|
||||||
|
|
||||||
Slic3r::GUI::load_language();
|
Slic3r::GUI::load_language();
|
||||||
|
|
||||||
@ -137,6 +128,7 @@ sub OnInit {
|
|||||||
);
|
);
|
||||||
$self->SetTopWindow($frame);
|
$self->SetTopWindow($frame);
|
||||||
|
|
||||||
|
# This makes CallAfter() work
|
||||||
EVT_IDLE($self->{mainframe}, sub {
|
EVT_IDLE($self->{mainframe}, sub {
|
||||||
while (my $cb = shift @cb) {
|
while (my $cb = shift @cb) {
|
||||||
$cb->();
|
$cb->();
|
||||||
@ -144,8 +136,21 @@ sub OnInit {
|
|||||||
$self->{app_config}->save if $self->{app_config}->dirty;
|
$self->{app_config}->save if $self->{app_config}->dirty;
|
||||||
});
|
});
|
||||||
|
|
||||||
# On OSX the UI was not initialized correctly if the wizard was called
|
# On OS X the UI tends to freeze in weird ways if modal dialogs (config wizard, update notifications, ...)
|
||||||
# before the UI was up and running.
|
# are shown before or in the same event callback with the main frame creation.
|
||||||
|
# Therefore we schedule them for later using CallAfter.
|
||||||
|
$self->CallAfter(sub {
|
||||||
|
eval {
|
||||||
|
if (! $self->{preset_updater}->config_update()) {
|
||||||
|
exit 0;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
if ($@) {
|
||||||
|
warn $@ . "\n";
|
||||||
|
fatal_error(undef, $@);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
$self->CallAfter(sub {
|
$self->CallAfter(sub {
|
||||||
if (! Slic3r::GUI::config_wizard_startup($app_conf_exists)) {
|
if (! Slic3r::GUI::config_wizard_startup($app_conf_exists)) {
|
||||||
# Only notify if there was not wizard so as not to bother too much ...
|
# Only notify if there was not wizard so as not to bother too much ...
|
||||||
|
@ -41,6 +41,7 @@ struct termios2 {
|
|||||||
|
|
||||||
//#define DEBUG_SERIAL
|
//#define DEBUG_SERIAL
|
||||||
#ifdef DEBUG_SERIAL
|
#ifdef DEBUG_SERIAL
|
||||||
|
#include <cstdlib>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
std::fstream fs;
|
std::fstream fs;
|
||||||
#endif
|
#endif
|
||||||
@ -52,7 +53,11 @@ namespace Slic3r {
|
|||||||
GCodeSender::GCodeSender()
|
GCodeSender::GCodeSender()
|
||||||
: io(), serial(io), can_send(false), sent(0), open(false), error(false),
|
: io(), serial(io), can_send(false), sent(0), open(false), error(false),
|
||||||
connected(false), queue_paused(false)
|
connected(false), queue_paused(false)
|
||||||
{}
|
{
|
||||||
|
#ifdef DEBUG_SERIAL
|
||||||
|
std::srand(std::time(nullptr));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
GCodeSender::~GCodeSender()
|
GCodeSender::~GCodeSender()
|
||||||
{
|
{
|
||||||
@ -358,15 +363,23 @@ GCodeSender::on_read(const boost::system::error_code& error,
|
|||||||
// extract the first number from line
|
// extract the first number from line
|
||||||
boost::algorithm::trim_left_if(line, !boost::algorithm::is_digit());
|
boost::algorithm::trim_left_if(line, !boost::algorithm::is_digit());
|
||||||
size_t toresend = boost::lexical_cast<size_t>(line.substr(0, line.find_first_not_of("0123456789")));
|
size_t toresend = boost::lexical_cast<size_t>(line.substr(0, line.find_first_not_of("0123456789")));
|
||||||
++ toresend; // N is 0-based
|
|
||||||
if (toresend >= this->sent - this->last_sent.size() && toresend < this->last_sent.size()) {
|
#ifdef DEBUG_SERIAL
|
||||||
|
fs << "!! line num out of sync: toresend = " << toresend << ", sent = " << sent << ", last_sent.size = " << last_sent.size() << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (toresend > this->sent - this->last_sent.size() && toresend <= this->sent) {
|
||||||
{
|
{
|
||||||
boost::lock_guard<boost::mutex> l(this->queue_mutex);
|
boost::lock_guard<boost::mutex> l(this->queue_mutex);
|
||||||
|
|
||||||
|
const auto lines_to_resend = this->sent - toresend + 1;
|
||||||
|
#ifdef DEBUG_SERIAL
|
||||||
|
fs << "!! resending " << lines_to_resend << " lines" << std::endl;
|
||||||
|
#endif
|
||||||
// move the unsent lines to priqueue
|
// move the unsent lines to priqueue
|
||||||
this->priqueue.insert(
|
this->priqueue.insert(
|
||||||
this->priqueue.begin(), // insert at the beginning
|
this->priqueue.begin(), // insert at the beginning
|
||||||
this->last_sent.begin() + toresend - (this->sent - this->last_sent.size()) - 1,
|
this->last_sent.begin() + this->last_sent.size() - lines_to_resend,
|
||||||
this->last_sent.end()
|
this->last_sent.end()
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -477,8 +490,14 @@ GCodeSender::do_send()
|
|||||||
if (line.empty()) return;
|
if (line.empty()) return;
|
||||||
|
|
||||||
// compute full line
|
// compute full line
|
||||||
std::string full_line = "N" + boost::lexical_cast<std::string>(this->sent) + " " + line;
|
|
||||||
++ this->sent;
|
++ this->sent;
|
||||||
|
#ifndef DEBUG_SERIAL
|
||||||
|
const auto line_num = this->sent;
|
||||||
|
#else
|
||||||
|
// In DEBUG_SERIAL mode, test line re-synchronization by sending bad line number 1/4 of the time
|
||||||
|
const auto line_num = std::rand() < RAND_MAX/4 ? 0 : this->sent;
|
||||||
|
#endif
|
||||||
|
std::string full_line = "N" + boost::lexical_cast<std::string>(line_num) + " " + line;
|
||||||
|
|
||||||
// calculate checksum
|
// calculate checksum
|
||||||
int cs = 0;
|
int cs = 0;
|
||||||
@ -497,8 +516,9 @@ GCodeSender::do_send()
|
|||||||
this->last_sent.push_back(line);
|
this->last_sent.push_back(line);
|
||||||
this->can_send = false;
|
this->can_send = false;
|
||||||
|
|
||||||
if (this->last_sent.size() > KEEP_SENT)
|
while (this->last_sent.size() > KEEP_SENT) {
|
||||||
this->last_sent.erase(this->last_sent.begin(), this->last_sent.end() - KEEP_SENT);
|
this->last_sent.pop_front();
|
||||||
|
}
|
||||||
|
|
||||||
// we can't supply boost::asio::buffer(full_line) to async_write() because full_line is on the
|
// we can't supply boost::asio::buffer(full_line) to async_write() because full_line is on the
|
||||||
// stack and the buffer would lose its underlying storage causing memory corruption
|
// stack and the buffer would lose its underlying storage causing memory corruption
|
||||||
|
@ -51,7 +51,7 @@ class GCodeSender : private boost::noncopyable {
|
|||||||
bool can_send;
|
bool can_send;
|
||||||
bool queue_paused;
|
bool queue_paused;
|
||||||
size_t sent;
|
size_t sent;
|
||||||
std::vector<std::string> last_sent;
|
std::deque<std::string> last_sent;
|
||||||
|
|
||||||
// this mutex guards log, T, B
|
// this mutex guards log, T, B
|
||||||
mutable boost::mutex log_mutex;
|
mutable boost::mutex log_mutex;
|
||||||
|
@ -358,8 +358,7 @@ void add_config_menu(wxMenuBar *menu, int event_preferences_changed, int event_l
|
|||||||
Config::SnapshotDB::singleton().restore_snapshot(dlg.snapshot_to_activate(), *g_AppConfig).id);
|
Config::SnapshotDB::singleton().restore_snapshot(dlg.snapshot_to_activate(), *g_AppConfig).id);
|
||||||
g_PresetBundle->load_presets(*g_AppConfig);
|
g_PresetBundle->load_presets(*g_AppConfig);
|
||||||
// Load the currently selected preset into the GUI, update the preset selection box.
|
// Load the currently selected preset into the GUI, update the preset selection box.
|
||||||
for (Tab *tab : g_tabs_list)
|
load_current_presets();
|
||||||
tab->load_current_preset();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -454,8 +453,7 @@ void config_wizard(int reason)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Load the currently selected preset into the GUI, update the preset selection box.
|
// Load the currently selected preset into the GUI, update the preset selection box.
|
||||||
for (Tab *tab : g_tabs_list)
|
load_current_presets();
|
||||||
tab->load_current_preset();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void open_preferences_dialog(int event_preferences)
|
void open_preferences_dialog(int event_preferences)
|
||||||
@ -607,6 +605,13 @@ void add_created_tab(Tab* panel)
|
|||||||
g_wxTabPanel->AddPage(panel, panel->title());
|
g_wxTabPanel->AddPage(panel, panel->title());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void load_current_presets()
|
||||||
|
{
|
||||||
|
for (Tab *tab : g_tabs_list) {
|
||||||
|
tab->load_current_preset();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void show_error(wxWindow* parent, const wxString& message) {
|
void show_error(wxWindow* parent, const wxString& message) {
|
||||||
ErrorDialog msg(parent, message);
|
ErrorDialog msg(parent, message);
|
||||||
msg.ShowModal();
|
msg.ShowModal();
|
||||||
|
@ -125,6 +125,9 @@ void add_created_tab(Tab* panel);
|
|||||||
// Change option value in config
|
// Change option value in config
|
||||||
void change_opt_value(DynamicPrintConfig& config, const t_config_option_key& opt_key, const boost::any& value, int opt_index = 0);
|
void change_opt_value(DynamicPrintConfig& config, const t_config_option_key& opt_key, const boost::any& value, int opt_index = 0);
|
||||||
|
|
||||||
|
// Update UI / Tabs to reflect changes in the currently loaded presets
|
||||||
|
void load_current_presets();
|
||||||
|
|
||||||
void show_error(wxWindow* parent, const wxString& message);
|
void show_error(wxWindow* parent, const wxString& message);
|
||||||
void show_error_id(int id, const std::string& message); // For Perl
|
void show_error_id(int id, const std::string& message); // For Perl
|
||||||
void show_info(wxWindow* parent, const wxString& message, const wxString& title);
|
void show_info(wxWindow* parent, const wxString& message, const wxString& title);
|
||||||
|
@ -101,6 +101,7 @@ PresetBundle::~PresetBundle()
|
|||||||
void PresetBundle::reset(bool delete_files)
|
void PresetBundle::reset(bool delete_files)
|
||||||
{
|
{
|
||||||
// Clear the existing presets, delete their respective files.
|
// Clear the existing presets, delete their respective files.
|
||||||
|
this->vendors.clear();
|
||||||
this->prints .reset(delete_files);
|
this->prints .reset(delete_files);
|
||||||
this->filaments.reset(delete_files);
|
this->filaments.reset(delete_files);
|
||||||
this->printers .reset(delete_files);
|
this->printers .reset(delete_files);
|
||||||
|
@ -162,7 +162,7 @@ bool PresetUpdater::priv::get_file(const std::string &url, const fs::path &targe
|
|||||||
% http_status
|
% http_status
|
||||||
% error;
|
% error;
|
||||||
})
|
})
|
||||||
.on_complete([&](std::string body, unsigned http_status) {
|
.on_complete([&](std::string body, unsigned /* http_status */) {
|
||||||
fs::fstream file(tmp_path, std::ios::out | std::ios::binary | std::ios::trunc);
|
fs::fstream file(tmp_path, std::ios::out | std::ios::binary | std::ios::trunc);
|
||||||
file.write(body.c_str(), body.size());
|
file.write(body.c_str(), body.size());
|
||||||
file.close();
|
file.close();
|
||||||
@ -204,7 +204,7 @@ void PresetUpdater::priv::sync_version() const
|
|||||||
% http_status
|
% http_status
|
||||||
% error;
|
% error;
|
||||||
})
|
})
|
||||||
.on_complete([&](std::string body, unsigned http_status) {
|
.on_complete([&](std::string body, unsigned /* http_status */) {
|
||||||
boost::trim(body);
|
boost::trim(body);
|
||||||
BOOST_LOG_TRIVIAL(info) << boost::format("Got Slic3rPE online version: `%1%`. Sending to GUI thread...") % body;
|
BOOST_LOG_TRIVIAL(info) << boost::format("Got Slic3rPE online version: `%1%`. Sending to GUI thread...") % body;
|
||||||
wxCommandEvent* evt = new wxCommandEvent(version_online_event);
|
wxCommandEvent* evt = new wxCommandEvent(version_online_event);
|
||||||
@ -553,6 +553,12 @@ bool PresetUpdater::config_update() const
|
|||||||
if (res == wxID_OK) {
|
if (res == wxID_OK) {
|
||||||
BOOST_LOG_TRIVIAL(debug) << "User agreed to perform the update";
|
BOOST_LOG_TRIVIAL(debug) << "User agreed to perform the update";
|
||||||
p->perform_updates(std::move(updates));
|
p->perform_updates(std::move(updates));
|
||||||
|
|
||||||
|
// Reload global configuration
|
||||||
|
auto *app_config = GUI::get_app_config();
|
||||||
|
app_config->reset_selections();
|
||||||
|
GUI::get_preset_bundle()->load_presets(*app_config);
|
||||||
|
GUI::load_current_presets();
|
||||||
} else {
|
} else {
|
||||||
BOOST_LOG_TRIVIAL(info) << "User refused the update";
|
BOOST_LOG_TRIVIAL(info) << "User refused the update";
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user