From f83213d9585582a5e341c9d8804951294d883d63 Mon Sep 17 00:00:00 2001 From: David Kocik Date: Mon, 6 May 2024 14:43:16 +0200 Subject: [PATCH] Fix of opening avatar file for write. --- src/slic3r/GUI/Plater.cpp | 4 ++++ src/slic3r/GUI/UserAccount.cpp | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index b48edca87c..256b3ec198 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -964,6 +964,10 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame) boost::filesystem::path path = user_account->get_avatar_path(true); FILE* file; file = fopen(path.string().c_str(), "wb"); + if (file == NULL) { + BOOST_LOG_TRIVIAL(error) << "Failed to create file to store avatar picture at: " << path; + return; + } fwrite(evt.data.c_str(), 1, evt.data.size(), file); fclose(file); this->main_frame->refresh_account_menu(true); diff --git a/src/slic3r/GUI/UserAccount.cpp b/src/slic3r/GUI/UserAccount.cpp index 992fc39b00..65c9bc40d1 100644 --- a/src/slic3r/GUI/UserAccount.cpp +++ b/src/slic3r/GUI/UserAccount.cpp @@ -1,6 +1,7 @@ #include "UserAccount.hpp" #include "format.hpp" +#include "GUI.hpp" #include "libslic3r/Utils.hpp" @@ -78,7 +79,7 @@ boost::filesystem::path UserAccount::get_avatar_path(bool logged) const { if (logged) { const std::string filename = "prusaslicer-avatar-" + m_instance_hash + m_avatar_extension; - return boost::filesystem::path(wxStandardPaths::Get().GetTempDir().utf8_str().data()) / filename; + return GUI::into_path(wxStandardPaths::Get().GetTempDir()) / filename; } else { return boost::filesystem::path(resources_dir()) / "icons" / "user.svg"; }