danielb6611 / mupen64plus

Automatically exported from code.google.com/p/mupen64plus
0 stars 0 forks source link

Take Screenshoot on Win7x64 make it crash #315

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Describe your system:
 - Win 7 x64
 - Mupen64Plus version: 1.99.2
 - Plugins used: RICE

When I push F12 to take a screenshoot on Win7, I have this message:

Core Error: MKDIR failed for 'C:\Documents and
Settings\dorian.fevrier\Application Data\Mupen64Plus\/screenshot/'.

So I've search, find and modify this:

screenshot.cpp

extern "C" void TakeScreenshot(int iFrameNumber)
snprintf(filepath, sizeof(filepath)-1, "%s/screenshot/",
ConfigGetUserDataPath());

to this:

screenshot.cpp

extern "C" void TakeScreenshot(int iFrameNumber)
snprintf(filepath, sizeof(filepath)-1, "%sscreenshot\\",
ConfigGetUserDataPath());

Now a zero byte (octet in french) file is created: goldeneye-000.png and
the mupen64plus crash.

I continue, after a lot of printf (my favorite "method" ^^ ), I change this:

    /* make sure there is a slash on the end of the pathname */
    if (strlen(filepath) > 0 && filepath[strlen(filepath)-1] != '/')
        strcat(filepath, "/"); //only for linux

to this (just for test, we have to find en cleanest method):

    if (strlen(filepath) > 0 && filepath[strlen(filepath)-1] != '\\')
        strcat(filepath, "\\"); //only windows ^^

I continue:

// look for a file
    int i;
    for (i = 0; i < 100; i++)
    {
        sprintf(filename, "%s-%03i.png", filepath, i);
        FILE *pFile = fopen(filename, "r");
        if (pFile == NULL)
            break;
        fclose(pFile);
    }
    if (i == 100) return; // maybe increase this value no? 100 seems to be
a little low but it's not the prob for now!

I continue:

    // Set the jumpback
    if (setjmp(png_jmpbuf(png_write)))
    {
        png_destroy_write_struct(&png_write, &png_info);
        DebugMessage(M64MSG_ERROR, "Error calling setjmp()");
        //fclose(pFile); <-- Missing?
        return 3;
    }

libpng manual (http://www.libpng.org/pub/png/libpng-manual.txt) talk about
open file to write first and add a fclose(fp) before return (on jumpback).
But it's not really important I suppose.

I continue again and, the app crash here:
screenshot.cpp
png_write_png(png_write, png_info, 0, NULL);

I suppose there is a difference between what we get and store from GL frame
buffer and what png need.

Someone have a Idea? Thank in advance ;)

Original issue reported on code.google.com by dorian.f...@gmail.com on 14 Jan 2010 at 4:45

GoogleCodeExporter commented 8 years ago

Original comment by richard...@gmail.com on 19 Jan 2010 at 3:24

GoogleCodeExporter commented 8 years ago
I have duplicated this bug under WinXP and committed a fix.  Please test on Win 
7 and
verify that the fix works for you as well.  The problem is that the libpng 
functions
were taking a FILE * from the caller (screenshot.cpp) and calling fwrite()
internally.  Probably the libpng was compiled with a different/incompatible C
library.  I modified the code to use callback functions instead and do the 
fwrite()
from within screenshot.cpp itself, and this works for me.

Original comment by richard...@gmail.com on 22 Jan 2010 at 5:22

GoogleCodeExporter commented 8 years ago
Great! Thanks! I will test soon!

Original comment by dorian.f...@gmail.com on 22 Jan 2010 at 8:04

GoogleCodeExporter commented 8 years ago
Test and work well:

Original comment by dorian.f...@gmail.com on 22 Jan 2010 at 2:34

Attachments: