mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-01 08:46:38 +02:00
Fix ordering problem with screenshots that was causing crashes.
Fixes #17781
This commit is contained in:
@@ -178,12 +178,13 @@ void ScreenManager::render() {
|
||||
iter++;
|
||||
}
|
||||
stack_.back().screen->render();
|
||||
if (postRenderCb_) {
|
||||
postRenderCb_(getUIContext(), postRenderUserdata_);
|
||||
}
|
||||
if (overlayScreen_) {
|
||||
overlayScreen_->render();
|
||||
}
|
||||
if (postRenderCb_) {
|
||||
// Really can't render anything after this! Will crash the screenshot mechanism if we do.
|
||||
postRenderCb_(getUIContext(), postRenderUserdata_);
|
||||
}
|
||||
first->screen->postRender();
|
||||
break;
|
||||
}
|
||||
@@ -191,11 +192,13 @@ void ScreenManager::render() {
|
||||
_assert_(stack_.back().screen);
|
||||
stack_.back().screen->preRender();
|
||||
stack_.back().screen->render();
|
||||
if (postRenderCb_)
|
||||
postRenderCb_(getUIContext(), postRenderUserdata_);
|
||||
if (overlayScreen_) {
|
||||
overlayScreen_->render();
|
||||
}
|
||||
if (postRenderCb_) {
|
||||
// Really can't render anything after this! Will crash the screenshot mechanism if we do.
|
||||
postRenderCb_(getUIContext(), postRenderUserdata_);
|
||||
}
|
||||
stack_.back().screen->postRender();
|
||||
break;
|
||||
}
|
||||
|
||||
+3
-2
@@ -359,8 +359,8 @@ bool TakeGameScreenshot(const Path &filename, ScreenshotFormat fmt, ScreenshotTy
|
||||
return false;
|
||||
}
|
||||
|
||||
u8 *flipbuffer = nullptr;
|
||||
if (success) {
|
||||
u8 *flipbuffer = nullptr;
|
||||
const u8 *buffer = ConvertBufferToScreenshot(buf, false, flipbuffer, w, h);
|
||||
success = buffer != nullptr;
|
||||
if (success) {
|
||||
@@ -371,12 +371,13 @@ bool TakeGameScreenshot(const Path &filename, ScreenshotFormat fmt, ScreenshotTy
|
||||
|
||||
success = Save888RGBScreenshot(filename, fmt, buffer, w, h);
|
||||
}
|
||||
delete[] flipbuffer;
|
||||
}
|
||||
delete [] flipbuffer;
|
||||
|
||||
if (!success) {
|
||||
ERROR_LOG(IO, "Failed to write screenshot.");
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,12 +24,12 @@
|
||||
#include "Common/Data/Text/I18n.h"
|
||||
#include "Common/StringUtils.h"
|
||||
|
||||
void TakeScreenshot();
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern bool g_TakeScreenshot;
|
||||
|
||||
#define MENU_ITEM(variableName, localizedTitleName, SEL, ConfigurationValueName, Tag) \
|
||||
NSMenuItem *variableName = [[NSMenuItem alloc] initWithTitle:localizedTitleName action:SEL keyEquivalent:@""]; \
|
||||
variableName.target = self; \
|
||||
@@ -488,7 +488,7 @@ void OSXOpenURL(const char *url) {
|
||||
}
|
||||
|
||||
-(void)takeScreenshot {
|
||||
TakeScreenshot();
|
||||
g_takeScreenshot = true;
|
||||
}
|
||||
|
||||
-(void)resetSymbolTable {
|
||||
|
||||
+5
-6
@@ -821,7 +821,7 @@ void NativeInit(int argc, const char *argv[], const char *savegame_dir, const ch
|
||||
restarting = false;
|
||||
}
|
||||
|
||||
void RenderOverlays(UIContext *dc, void *userdata);
|
||||
void CallbackPostRender(UIContext *dc, void *userdata);
|
||||
bool CreateGlobalPipelines();
|
||||
|
||||
bool NativeInitGraphics(GraphicsContext *graphicsContext) {
|
||||
@@ -860,7 +860,7 @@ bool NativeInitGraphics(GraphicsContext *graphicsContext) {
|
||||
|
||||
g_screenManager->setUIContext(uiContext);
|
||||
g_screenManager->setDrawContext(g_draw);
|
||||
g_screenManager->setPostRenderCallback(&RenderOverlays, nullptr);
|
||||
g_screenManager->setPostRenderCallback(&CallbackPostRender, nullptr);
|
||||
g_screenManager->deviceRestored();
|
||||
|
||||
#ifdef _WIN32
|
||||
@@ -993,9 +993,7 @@ void NativeShutdownGraphics() {
|
||||
INFO_LOG(SYSTEM, "NativeShutdownGraphics done");
|
||||
}
|
||||
|
||||
void TakeScreenshot() {
|
||||
g_TakeScreenshot = false;
|
||||
|
||||
static void TakeScreenshot() {
|
||||
Path path = GetSysDirectory(DIRECTORY_SCREENSHOT);
|
||||
if (!File::Exists(path)) {
|
||||
File::CreateDir(path);
|
||||
@@ -1027,9 +1025,10 @@ void TakeScreenshot() {
|
||||
}
|
||||
}
|
||||
|
||||
void RenderOverlays(UIContext *dc, void *userdata) {
|
||||
void CallbackPostRender(UIContext *dc, void *userdata) {
|
||||
if (g_TakeScreenshot) {
|
||||
TakeScreenshot();
|
||||
g_TakeScreenshot = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user