added file existence check

pull/1846/head
Dordovel 2022-11-29 09:00:12 +03:00
parent da3d9533d1
commit 7671ccfbc6
1 changed files with 7 additions and 2 deletions

View File

@ -10,6 +10,7 @@
#include "gdkmm/cursor.h" #include "gdkmm/cursor.h"
#include "gdkmm/event.h" #include "gdkmm/event.h"
#include "gdkmm/types.h" #include "gdkmm/types.h"
#include "glibmm/fileutils.h"
#include "sigc++/functors/mem_fun.h" #include "sigc++/functors/mem_fun.h"
#include "sigc++/functors/ptr_fun.h" #include "sigc++/functors/ptr_fun.h"
@ -106,8 +107,12 @@ void User::init_default_user_avatar(int width, int height) {
} }
void User::init_user_avatar(const std::string& path, int width, int height) { void User::init_user_avatar(const std::string& path, int width, int height) {
Glib::RefPtr<Gdk::Pixbuf> pixbuf_ = Gdk::Pixbuf::create_from_file(path, width, height); if (Glib::file_test(path, Glib::FILE_TEST_EXISTS)) {
AIconLabel::image_.set(pixbuf_); Glib::RefPtr<Gdk::Pixbuf> pixbuf_ = Gdk::Pixbuf::create_from_file(path, width, height);
AIconLabel::image_.set(pixbuf_);
} else {
AIconLabel::box_.remove(AIconLabel::image_);
}
} }
auto User::update() -> void { auto User::update() -> void {