summaryrefslogtreecommitdiffstats
path: root/src/display/cairo-utils.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/display/cairo-utils.cpp')
-rw-r--r--src/display/cairo-utils.cpp29
1 files changed, 26 insertions, 3 deletions
diff --git a/src/display/cairo-utils.cpp b/src/display/cairo-utils.cpp
index c640de13b..82373c27c 100644
--- a/src/display/cairo-utils.cpp
+++ b/src/display/cairo-utils.cpp
@@ -303,13 +303,34 @@ Pixbuf *Pixbuf::create_from_file(std::string const &fn)
// since we'll store it as MIME data
gchar *data = NULL;
gsize len = 0;
- GError *error;
+ GError *error = NULL;
if (g_file_get_contents(fn.c_str(), &data, &len, &error)) {
+ if (error != NULL) {
+ std::cerr << "Pixbuf::create_from_file: " << error->message << std::endl;
+ std::cerr << " (" << fn << ")" << std::endl;
+ return NULL;
+ }
+
GdkPixbufLoader *loader = gdk_pixbuf_loader_new();
- gdk_pixbuf_loader_write(loader, (guchar *) data, len, NULL);
- gdk_pixbuf_loader_close(loader, NULL);
+ gdk_pixbuf_loader_write(loader, (guchar *) data, len, &error);
+ if (error != NULL) {
+ std::cerr << "Pixbuf::create_from_file: " << error->message << std::endl;
+ std::cerr << " (" << fn << ")" << std::endl;
+ g_free(data);
+ g_object_unref(loader);
+ return NULL;
+ }
+
+ gdk_pixbuf_loader_close(loader, &error);
+ if (error != NULL) {
+ std::cerr << "Pixbuf::create_from_file: " << error->message << std::endl;
+ std::cerr << " (" << fn << ")" << std::endl;
+ g_free(data);
+ g_object_unref(loader);
+ return NULL;
+ }
GdkPixbuf *buf = gdk_pixbuf_loader_get_pixbuf(loader);
if (buf) {
@@ -323,6 +344,7 @@ Pixbuf *Pixbuf::create_from_file(std::string const &fn)
pb->_setMimeData((guchar *) data, len, fmt_name);
g_free(fmt_name);
} else {
+ std::cerr << "Pixbuf::create_from_file: failed to load contents: " << fn << std::endl;
g_free(data);
}
g_object_unref(loader);
@@ -330,6 +352,7 @@ Pixbuf *Pixbuf::create_from_file(std::string const &fn)
// TODO: we could also read DPI, ICC profile, gamma correction, and other information
// from the file. This can be done by using format-specific libraries e.g. libpng.
} else {
+ std::cerr << "Pixbuf::create_from_file: failed to get contents: " << fn << std::endl;
return NULL;
}