diff options
Diffstat (limited to 'libs/gtkmm2ext/motionfeedback.cc')
-rw-r--r-- | libs/gtkmm2ext/motionfeedback.cc | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/libs/gtkmm2ext/motionfeedback.cc b/libs/gtkmm2ext/motionfeedback.cc index ead2b26885..bef934eca5 100644 --- a/libs/gtkmm2ext/motionfeedback.cc +++ b/libs/gtkmm2ext/motionfeedback.cc @@ -25,6 +25,8 @@ #include <unistd.h> #include <stdio.h> /* for snprintf, grrr */ +#include <glib/gstdio.h> + #include <gdk/gdkkeysyms.h> #include <gtkmm.h> @@ -468,14 +470,18 @@ Glib::RefPtr<Gdk::Pixbuf> MotionFeedback::render_pixbuf (int size) { Glib::RefPtr<Gdk::Pixbuf> pixbuf; - char path[32]; + char *path; int fd; + GError *error = NULL; - snprintf (path, sizeof (path), "/tmp/mfimg%dXXXXXX", size); - - if ((fd = mkstemp (path)) < 0) { + fd = g_file_open_tmp ("mfimgXXXXXX", &path, &error); + close (fd); + + if(error) { + g_critical("failed to open a temporary file for writing: %s.", error->message); + g_error_free (error); return pixbuf; - } + } GdkColor col2 = {0,0,0,0}; GdkColor col3 = {0,0,0,0}; @@ -512,15 +518,17 @@ MotionFeedback::render_pixbuf (int size) pixbuf = Gdk::Pixbuf::create_from_file (path); } catch (const Gdk::PixbufError &e) { std::cerr << "Caught PixbufError: " << e.what() << std::endl; - unlink (path); + ::g_unlink (path); throw; } catch (...) { - unlink (path); + ::g_unlink (path); g_message("Caught ... "); throw; } - unlink (path); + ::g_unlink (path); + + g_free(path); return pixbuf; } |