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;
|
||||
}
|
||||
}
|
||||
pCaptureTexture->nLockRefs--;
|
||||
|
||||
char pTimeBuffer[1024];
|
||||
time_t currentTime = time(0);
|
||||
struct tm *localTime = localtime( ¤tTime );
|
||||
strftime( pTimeBuffer, sizeof( pTimeBuffer ), "/tmp/gamescope_%Y-%m-%d_%H-%M-%S.png", localTime );
|
||||
|
||||
stbi_write_png(pTimeBuffer, currentOutputWidth, currentOutputHeight, 4, imageData.data(), pitch);
|
||||
|
||||
pCaptureTexture->nLockRefs--;
|
||||
|
||||
xwm_log.infof("Screenshot saved to %s", pTimeBuffer);
|
||||
if ( stbi_write_png(pTimeBuffer, currentOutputWidth, currentOutputHeight, 4, imageData.data(), pitch) )
|
||||
{
|
||||
xwm_log.infof("Screenshot saved to %s", pTimeBuffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
xwm_log.errorf( "Failed to save screenshot to %s", pTimeBuffer );
|
||||
}
|
||||
});
|
||||
|
||||
screenshotThread.detach();
|
||||
|
|
Loading…
Reference in a new issue