don't clobber existing screenshots
This commit is contained in:
parent
35e834ff2c
commit
a3eebbac21
|
@ -218,7 +218,7 @@ void on_menu_quit_activate (GtkMenuItem *menuitem, gpointer user_data) { gtk
|
|||
static void Printscreen()
|
||||
{
|
||||
GdkPixbuf *screenshot;
|
||||
gchar *filename;
|
||||
gchar *filename = NULL;
|
||||
GError *error = NULL;
|
||||
u8 *rgb;
|
||||
u16 *gpuFramebuffer = (u16 *)GPU->GetDisplayInfo().masterNativeBuffer;
|
||||
|
@ -243,13 +243,17 @@ static void Printscreen()
|
|||
NULL,
|
||||
NULL);
|
||||
|
||||
filename = g_strdup_printf("./desmume-screenshot-%d.png", seq);
|
||||
gdk_pixbuf_save(screenshot, filename, "png", &error, NULL);
|
||||
do {
|
||||
g_free(filename);
|
||||
filename = g_strdup_printf("./desmume-screenshot-%d.png", seq++);
|
||||
}
|
||||
while (g_file_test(filename, G_FILE_TEST_EXISTS));
|
||||
|
||||
gdk_pixbuf_save(screenshot, filename, "png", &error, NULL);
|
||||
if (error) {
|
||||
g_error_free (error);
|
||||
g_printerr("Failed to save %s", filename);
|
||||
} else {
|
||||
seq++;
|
||||
seq--;
|
||||
}
|
||||
|
||||
free(rgb);
|
||||
|
|
|
@ -2359,7 +2359,7 @@ static void Printscreen()
|
|||
{
|
||||
GdkPixbuf *screenshot;
|
||||
const gchar *dir;
|
||||
gchar *filename, *filen;
|
||||
gchar *filename = NULL, *filen = NULL;
|
||||
GError *error = NULL;
|
||||
u8 rgb[256 * 384 * 4];
|
||||
static int seq = 0;
|
||||
|
@ -2396,15 +2396,19 @@ static void Printscreen()
|
|||
dir = g_get_home_dir();
|
||||
}
|
||||
|
||||
filen = g_strdup_printf("desmume-screenshot-%d.png", seq);
|
||||
filename = g_build_filename(dir, filen, NULL);
|
||||
do {
|
||||
g_free(filen);
|
||||
g_free(filename);
|
||||
filen = g_strdup_printf("desmume-screenshot-%d.png", seq++);
|
||||
filename = g_build_filename(dir, filen, NULL);
|
||||
}
|
||||
while (g_file_test(filename, G_FILE_TEST_EXISTS));
|
||||
|
||||
gdk_pixbuf_save(screenshot, filename, "png", &error, NULL);
|
||||
if (error) {
|
||||
g_error_free (error);
|
||||
g_printerr("Failed to save %s", filename);
|
||||
} else {
|
||||
seq++;
|
||||
seq--;
|
||||
}
|
||||
|
||||
//free(rgb);
|
||||
|
|
Loading…
Reference in New Issue