Fix of opening avatar file for write.

This commit is contained in:
David Kocik 2024-05-06 14:43:16 +02:00
parent 2de65cfa6a
commit f83213d958
2 changed files with 6 additions and 1 deletions

View File

@ -964,6 +964,10 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame)
boost::filesystem::path path = user_account->get_avatar_path(true); boost::filesystem::path path = user_account->get_avatar_path(true);
FILE* file; FILE* file;
file = fopen(path.string().c_str(), "wb"); 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); fwrite(evt.data.c_str(), 1, evt.data.size(), file);
fclose(file); fclose(file);
this->main_frame->refresh_account_menu(true); this->main_frame->refresh_account_menu(true);

View File

@ -1,6 +1,7 @@
#include "UserAccount.hpp" #include "UserAccount.hpp"
#include "format.hpp" #include "format.hpp"
#include "GUI.hpp"
#include "libslic3r/Utils.hpp" #include "libslic3r/Utils.hpp"
@ -78,7 +79,7 @@ boost::filesystem::path UserAccount::get_avatar_path(bool logged) const
{ {
if (logged) { if (logged) {
const std::string filename = "prusaslicer-avatar-" + m_instance_hash + m_avatar_extension; 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 { } else {
return boost::filesystem::path(resources_dir()) / "icons" / "user.svg"; return boost::filesystem::path(resources_dir()) / "icons" / "user.svg";
} }