Fixes of AppUdpater
fix of bug (1) - order of dialogs fix of bug (2) - show new version dialog when triggered by user fix of bug (3) - refresh value in preferences combobox when opening preferences fix of bug (4) - Use fwrite instead of stream to speedup saving. Do not show checkbox when triggered by user.
This commit is contained in:
parent
d681b99c10
commit
70879d2d8c
@ -811,13 +811,14 @@ void GUI_App::post_init()
|
|||||||
// preset_updater->sync downloads profile updates on background so it must begin after config wizard finished.
|
// preset_updater->sync downloads profile updates on background so it must begin after config wizard finished.
|
||||||
bool cw_showed = this->config_wizard_startup();
|
bool cw_showed = this->config_wizard_startup();
|
||||||
this->preset_updater->sync(preset_bundle);
|
this->preset_updater->sync(preset_bundle);
|
||||||
this->app_version_check(false);
|
|
||||||
if (! cw_showed) {
|
if (! cw_showed) {
|
||||||
// The CallAfter is needed as well, without it, GL extensions did not show.
|
// The CallAfter is needed as well, without it, GL extensions did not show.
|
||||||
// Also, we only want to show this when the wizard does not, so the new user
|
// Also, we only want to show this when the wizard does not, so the new user
|
||||||
// sees something else than "we want something" on the first start.
|
// sees something else than "we want something" on the first start.
|
||||||
show_send_system_info_dialog_if_needed();
|
show_send_system_info_dialog_if_needed();
|
||||||
}
|
}
|
||||||
|
// app version check is asynchronous and triggers blocking dialog window, better call it last
|
||||||
|
this->app_version_check(false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1245,7 +1246,7 @@ bool GUI_App::on_init_inner()
|
|||||||
preset_updater = new PresetUpdater();
|
preset_updater = new PresetUpdater();
|
||||||
Bind(EVT_SLIC3R_VERSION_ONLINE, &GUI_App::on_version_read, this);
|
Bind(EVT_SLIC3R_VERSION_ONLINE, &GUI_App::on_version_read, this);
|
||||||
Bind(EVT_SLIC3R_EXPERIMENTAL_VERSION_ONLINE, [this](const wxCommandEvent& evt) {
|
Bind(EVT_SLIC3R_EXPERIMENTAL_VERSION_ONLINE, [this](const wxCommandEvent& evt) {
|
||||||
if (this->plater_ != nullptr && app_config->get("notify_release") == "all") {
|
if (this->plater_ != nullptr && (m_app_updater->get_triggered_by_user() || app_config->get("notify_release") == "all")) {
|
||||||
std::string evt_string = into_u8(evt.GetString());
|
std::string evt_string = into_u8(evt.GetString());
|
||||||
if (*Semver::parse(SLIC3R_VERSION) < *Semver::parse(evt_string)) {
|
if (*Semver::parse(SLIC3R_VERSION) < *Semver::parse(evt_string)) {
|
||||||
auto notif_type = (evt_string.find("beta") != std::string::npos ? NotificationType::NewBetaAvailable : NotificationType::NewAlphaAvailable);
|
auto notif_type = (evt_string.find("beta") != std::string::npos ? NotificationType::NewBetaAvailable : NotificationType::NewAlphaAvailable);
|
||||||
@ -3305,7 +3306,8 @@ void GUI_App::on_version_read(wxCommandEvent& evt)
|
|||||||
app_config->set("version_online", into_u8(evt.GetString()));
|
app_config->set("version_online", into_u8(evt.GetString()));
|
||||||
app_config->save();
|
app_config->save();
|
||||||
std::string opt = app_config->get("notify_release");
|
std::string opt = app_config->get("notify_release");
|
||||||
if (this->plater_ == nullptr || (opt != "all" && opt != "release")) {
|
if (this->plater_ == nullptr || (!m_app_updater->get_triggered_by_user() && opt != "all" && opt != "release")) {
|
||||||
|
BOOST_LOG_TRIVIAL(info) << "Version online: " << evt.GetString() << ". User does not wish to be notified.";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (*Semver::parse(SLIC3R_VERSION) >= *Semver::parse(into_u8(evt.GetString()))) {
|
if (*Semver::parse(SLIC3R_VERSION) >= *Semver::parse(into_u8(evt.GetString()))) {
|
||||||
@ -3355,7 +3357,7 @@ void GUI_App::app_updater(bool from_user)
|
|||||||
assert(!app_data.target_path.empty());
|
assert(!app_data.target_path.empty());
|
||||||
|
|
||||||
// dialog with new version info
|
// dialog with new version info
|
||||||
AppUpdateAvailableDialog dialog(*Semver::parse(SLIC3R_VERSION), *app_data.version);
|
AppUpdateAvailableDialog dialog(*Semver::parse(SLIC3R_VERSION), *app_data.version, from_user);
|
||||||
auto dialog_result = dialog.ShowModal();
|
auto dialog_result = dialog.ShowModal();
|
||||||
// checkbox "do not show again"
|
// checkbox "do not show again"
|
||||||
if (dialog.disable_version_check()) {
|
if (dialog.disable_version_check()) {
|
||||||
|
@ -89,6 +89,13 @@ void PreferencesDialog::show(const std::string& highlight_opt_key /*= std::strin
|
|||||||
m_custom_toolbar_size = atoi(get_app_config()->get("custom_toolbar_size").c_str());
|
m_custom_toolbar_size = atoi(get_app_config()->get("custom_toolbar_size").c_str());
|
||||||
m_use_custom_toolbar_size = get_app_config()->get("use_custom_toolbar_size") == "1";
|
m_use_custom_toolbar_size = get_app_config()->get("use_custom_toolbar_size") == "1";
|
||||||
|
|
||||||
|
// set Field for notify_release to its value
|
||||||
|
if (m_optgroup_gui && m_optgroup_gui->get_field("notify_release") != nullptr) {
|
||||||
|
boost::any val = s_keys_map_NotifyReleaseMode.at(wxGetApp().app_config->get("notify_release"));
|
||||||
|
m_optgroup_gui->get_field("notify_release")->set_value(val, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (wxGetApp().is_editor()) {
|
if (wxGetApp().is_editor()) {
|
||||||
auto app_config = get_app_config();
|
auto app_config = get_app_config();
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ bool MsgUpdateSlic3r::disable_version_check() const
|
|||||||
|
|
||||||
wxSize AppUpdateAvailableDialog::AUAD_size;
|
wxSize AppUpdateAvailableDialog::AUAD_size;
|
||||||
// AppUpdater
|
// AppUpdater
|
||||||
AppUpdateAvailableDialog::AppUpdateAvailableDialog(const Semver& ver_current, const Semver& ver_online)
|
AppUpdateAvailableDialog::AppUpdateAvailableDialog(const Semver& ver_current, const Semver& ver_online, bool from_user)
|
||||||
: MsgDialog(nullptr, _(L("App Update available")), wxString::Format(_(L("New version of %s is available.\nDo you wish to download it?")), SLIC3R_APP_NAME))
|
: MsgDialog(nullptr, _(L("App Update available")), wxString::Format(_(L("New version of %s is available.\nDo you wish to download it?")), SLIC3R_APP_NAME))
|
||||||
{
|
{
|
||||||
auto* versions = new wxFlexGridSizer(1, 0, VERT_SPACING);
|
auto* versions = new wxFlexGridSizer(1, 0, VERT_SPACING);
|
||||||
@ -104,8 +104,10 @@ AppUpdateAvailableDialog::AppUpdateAvailableDialog(const Semver& ver_current, co
|
|||||||
content_sizer->Add(versions);
|
content_sizer->Add(versions);
|
||||||
content_sizer->AddSpacer(VERT_SPACING);
|
content_sizer->AddSpacer(VERT_SPACING);
|
||||||
|
|
||||||
cbox = new wxCheckBox(this, wxID_ANY, _(L("Don't notify about new releases any more")));
|
if(!from_user) {
|
||||||
content_sizer->Add(cbox);
|
cbox = new wxCheckBox(this, wxID_ANY, _(L("Don't notify about new releases any more")));
|
||||||
|
content_sizer->Add(cbox);
|
||||||
|
}
|
||||||
content_sizer->AddSpacer(VERT_SPACING);
|
content_sizer->AddSpacer(VERT_SPACING);
|
||||||
|
|
||||||
AUAD_size = content_sizer->GetSize();
|
AUAD_size = content_sizer->GetSize();
|
||||||
@ -125,6 +127,8 @@ AppUpdateAvailableDialog::~AppUpdateAvailableDialog() {}
|
|||||||
|
|
||||||
bool AppUpdateAvailableDialog::disable_version_check() const
|
bool AppUpdateAvailableDialog::disable_version_check() const
|
||||||
{
|
{
|
||||||
|
if (!cbox)
|
||||||
|
return false;
|
||||||
return cbox->GetValue();
|
return cbox->GetValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ private:
|
|||||||
class AppUpdateAvailableDialog : public MsgDialog
|
class AppUpdateAvailableDialog : public MsgDialog
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
AppUpdateAvailableDialog(const Semver& ver_current, const Semver& ver_online);
|
AppUpdateAvailableDialog(const Semver& ver_current, const Semver& ver_online, bool from_user);
|
||||||
AppUpdateAvailableDialog(AppUpdateAvailableDialog&&) = delete;
|
AppUpdateAvailableDialog(AppUpdateAvailableDialog&&) = delete;
|
||||||
AppUpdateAvailableDialog(const AppUpdateAvailableDialog&) = delete;
|
AppUpdateAvailableDialog(const AppUpdateAvailableDialog&) = delete;
|
||||||
AppUpdateAvailableDialog& operator=(AppUpdateAvailableDialog&&) = delete;
|
AppUpdateAvailableDialog& operator=(AppUpdateAvailableDialog&&) = delete;
|
||||||
@ -53,7 +53,7 @@ public:
|
|||||||
bool disable_version_check() const;
|
bool disable_version_check() const;
|
||||||
static wxSize AUAD_size;
|
static wxSize AUAD_size;
|
||||||
private:
|
private:
|
||||||
wxCheckBox* cbox;
|
wxCheckBox* cbox {nullptr};
|
||||||
};
|
};
|
||||||
|
|
||||||
class AppUpdateDownloadDialog : public MsgDialog
|
class AppUpdateDownloadDialog : public MsgDialog
|
||||||
|
@ -221,7 +221,7 @@ boost::filesystem::path AppUpdater::priv::download_file(const DownloadAppData& d
|
|||||||
}
|
}
|
||||||
// progress event
|
// progress event
|
||||||
size_t gui_progress = progress.dltotal > 0 ? 100 * progress.dlnow / progress.dltotal : 0;
|
size_t gui_progress = progress.dltotal > 0 ? 100 * progress.dlnow / progress.dltotal : 0;
|
||||||
BOOST_LOG_TRIVIAL(error) << "App download " << gui_progress << "% " << progress.dlnow << " of " << progress.dltotal;
|
BOOST_LOG_TRIVIAL(debug) << "App download " << gui_progress << "% " << progress.dlnow << " of " << progress.dltotal;
|
||||||
if (last_gui_progress < gui_progress && (last_gui_progress != 0 || gui_progress != 100)) {
|
if (last_gui_progress < gui_progress && (last_gui_progress != 0 || gui_progress != 100)) {
|
||||||
last_gui_progress = gui_progress;
|
last_gui_progress = gui_progress;
|
||||||
wxCommandEvent* evt = new wxCommandEvent(EVT_SLIC3R_APP_DOWNLOAD_PROGRESS);
|
wxCommandEvent* evt = new wxCommandEvent(EVT_SLIC3R_APP_DOWNLOAD_PROGRESS);
|
||||||
@ -243,14 +243,15 @@ boost::filesystem::path AppUpdater::priv::download_file(const DownloadAppData& d
|
|||||||
tmp_path += format(".%1%%2%", get_current_pid(), ".download");
|
tmp_path += format(".%1%%2%", get_current_pid(), ".download");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
boost::nowide::fstream file(tmp_path.string(), std::ios::out | std::ios::binary | std::ios::trunc);
|
FILE* file;
|
||||||
file.write(body.c_str(), body.size());
|
file = fopen(tmp_path.string().c_str(), "wb");
|
||||||
file.close();
|
fwrite(body.c_str(), 1, body.size(), file);
|
||||||
|
fclose(file);
|
||||||
boost::filesystem::rename(tmp_path, dest_path);
|
boost::filesystem::rename(tmp_path, dest_path);
|
||||||
}
|
}
|
||||||
catch (const std::exception&)
|
catch (const std::exception& e)
|
||||||
{
|
{
|
||||||
error_message = GUI::format("Failed to write and move %1% to %2%", tmp_path, dest_path);
|
error_message = GUI::format("Failed to write and move %1% to %2%:/n%3%", tmp_path, dest_path, e.what());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -363,10 +364,10 @@ void AppUpdater::priv::parse_version_string(const std::string& body)
|
|||||||
if (data.first == "url") {
|
if (data.first == "url") {
|
||||||
new_data.url = data.second.data();
|
new_data.url = data.second.data();
|
||||||
new_data.target_path = m_default_dest_folder / AppUpdater::get_filename_from_url(new_data.url);
|
new_data.target_path = m_default_dest_folder / AppUpdater::get_filename_from_url(new_data.url);
|
||||||
BOOST_LOG_TRIVIAL(error) << format("parsing version string: url: %1%", new_data.url);
|
BOOST_LOG_TRIVIAL(info) << format("parsing version string: url: %1%", new_data.url);
|
||||||
} else if (data.first == "size"){
|
} else if (data.first == "size"){
|
||||||
new_data.size = std::stoi(data.second.data());
|
new_data.size = std::stoi(data.second.data());
|
||||||
BOOST_LOG_TRIVIAL(error) << format("parsing version string: expected size: %1%", new_data.size);
|
BOOST_LOG_TRIVIAL(info) << format("parsing version string: expected size: %1%", new_data.size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user