Fix crash when generating screenshots (F9 key)
Signed-off-by: falkTX <falktx@falktx.com>
This commit is contained in:
parent
1c6cc082d9
commit
08763a2318
2 changed files with 9 additions and 6 deletions
|
@ -72,7 +72,7 @@ void Engine_setAboutToClose(Engine*);
|
|||
void Engine_setRemoteDetails(Engine*, remoteUtils::RemoteDetails*);
|
||||
}
|
||||
namespace window {
|
||||
void WindowSetPluginUI(Window* window, DISTRHO_NAMESPACE::UI* ui);
|
||||
void WindowSetPluginUI(Window* window, CardinalBaseUI* ui);
|
||||
void WindowSetMods(Window* window, int mods);
|
||||
void WindowSetInternalSize(rack::window::Window* window, math::Vec size);
|
||||
}
|
||||
|
|
|
@ -153,7 +153,7 @@ enum ScreenshotStep {
|
|||
struct Window::Internal {
|
||||
std::string lastWindowTitle;
|
||||
|
||||
DISTRHO_NAMESPACE::UI* ui = nullptr;
|
||||
CardinalBaseUI* ui = nullptr;
|
||||
DGL_NAMESPACE::NanoTopLevelWidget* tlw = nullptr;
|
||||
DISTRHO_NAMESPACE::WindowParameters params;
|
||||
DISTRHO_NAMESPACE::WindowParametersCallback* callback = nullptr;
|
||||
|
@ -370,7 +370,7 @@ void WindowSetPluginRemote(Window* const window, NanoTopLevelWidget* const tlw)
|
|||
}
|
||||
}
|
||||
|
||||
void WindowSetPluginUI(Window* const window, DISTRHO_NAMESPACE::UI* const ui)
|
||||
void WindowSetPluginUI(Window* const window, CardinalBaseUI* const ui)
|
||||
{
|
||||
// if nanovg context failed, init only bare minimum
|
||||
if (window->vg == nullptr)
|
||||
|
@ -598,6 +598,7 @@ static void Window__writeImagePNG(void* context, void* data, int size) {
|
|||
CardinalBaseUI* const ui = static_cast<CardinalBaseUI*>(context);
|
||||
if (char* const screenshot = String::asBase64(data, size).getAndReleaseBuffer()) {
|
||||
ui->setState("screenshot", screenshot);
|
||||
if (ui->remoteDetails != nullptr)
|
||||
remoteUtils::sendScreenshotToRemote(ui->remoteDetails, screenshot);
|
||||
std::free(screenshot);
|
||||
}
|
||||
|
@ -731,10 +732,10 @@ void Window::step() {
|
|||
if (internal->generateScreenshotStep == kScreenshotStepSaving)
|
||||
{
|
||||
// Write pixels to PNG
|
||||
const int stride = winWidth * depth;
|
||||
uint8_t* const pixelsWithOffset = pixels + (stride * y);
|
||||
Window__flipBitmap(pixels, winWidth, winHeight, depth);
|
||||
winHeight -= y;
|
||||
const int stride = winWidth * depth;
|
||||
uint8_t* const pixelsWithOffset = pixels + (stride * y);
|
||||
#ifdef STBI_WRITE_NO_STDIO
|
||||
Window__downscaleBitmap(pixelsWithOffset, winWidth, winHeight);
|
||||
stbi_write_png_to_func(Window__writeImagePNG, internal->ui,
|
||||
|
@ -744,8 +745,10 @@ void Window::step() {
|
|||
#endif
|
||||
|
||||
internal->generateScreenshotStep = kScreenshotStepNone;
|
||||
#ifdef CARDINAL_TRANSPARENT_SCREENSHOTS
|
||||
APP->scene->menuBar->show();
|
||||
APP->scene->rack->children.front()->show();
|
||||
#endif
|
||||
}
|
||||
|
||||
delete[] pixels;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue