From 965883bc223afe07ebcbb693e1108b419826d399 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 11 Jul 2013 15:15:40 -0400 Subject: [PATCH] Use Glib functions to create tmp file path --- libs/gtkmm2ext/motionfeedback.cc | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/libs/gtkmm2ext/motionfeedback.cc b/libs/gtkmm2ext/motionfeedback.cc index 44fb3e5f47..bd0fd1cd73 100644 --- a/libs/gtkmm2ext/motionfeedback.cc +++ b/libs/gtkmm2ext/motionfeedback.cc @@ -468,14 +468,18 @@ Glib::RefPtr MotionFeedback::render_pixbuf (int size) { Glib::RefPtr 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}; @@ -522,6 +526,8 @@ MotionFeedback::render_pixbuf (int size) unlink (path); + g_free(path); + return pixbuf; }