Add error handling to screenshot saving
This commit is contained in:
parent
0aa6761157
commit
c7a22d4777
1 changed files with 9 additions and 5 deletions
|
@ -1441,17 +1441,21 @@ paint_all(Display *dpy, MouseCursor *cursor)
|
||||||
imageData[y * pitch + x * comp + 3] = 255;
|
imageData[y * pitch + x * comp + 3] = 255;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
pCaptureTexture->nLockRefs--;
|
||||||
|
|
||||||
char pTimeBuffer[1024];
|
char pTimeBuffer[1024];
|
||||||
time_t currentTime = time(0);
|
time_t currentTime = time(0);
|
||||||
struct tm *localTime = localtime( ¤tTime );
|
struct tm *localTime = localtime( ¤tTime );
|
||||||
strftime( pTimeBuffer, sizeof( pTimeBuffer ), "/tmp/gamescope_%Y-%m-%d_%H-%M-%S.png", localTime );
|
strftime( pTimeBuffer, sizeof( pTimeBuffer ), "/tmp/gamescope_%Y-%m-%d_%H-%M-%S.png", localTime );
|
||||||
|
|
||||||
stbi_write_png(pTimeBuffer, currentOutputWidth, currentOutputHeight, 4, imageData.data(), pitch);
|
if ( stbi_write_png(pTimeBuffer, currentOutputWidth, currentOutputHeight, 4, imageData.data(), pitch) )
|
||||||
|
{
|
||||||
pCaptureTexture->nLockRefs--;
|
|
||||||
|
|
||||||
xwm_log.infof("Screenshot saved to %s", pTimeBuffer);
|
xwm_log.infof("Screenshot saved to %s", pTimeBuffer);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
xwm_log.errorf( "Failed to save screenshot to %s", pTimeBuffer );
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
screenshotThread.detach();
|
screenshotThread.detach();
|
||||||
|
|
Loading…
Reference in a new issue