Commit 95c8203f authored by Stephen Anthony's avatar Stephen Anthony
Browse files

Fix final issue with snapshots not loading in RomInfoWidget.

parent 3a54adec
Pipeline #12122 passed with stages
in 2 minutes and 1 second
......@@ -71,8 +71,6 @@ FBBackendSDL2::~FBBackendSDL2()
myWindow = nullptr;
}
SDL_QuitSubSystem(SDL_INIT_VIDEO | SDL_INIT_TIMER);
cerr << "~FBBackendSDL2()" << endl;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
......
......@@ -40,8 +40,6 @@ namespace {
}
}
static int REF_COUNT = 0;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FBSurfaceSDL2::FBSurfaceSDL2(FBBackendSDL2& backend,
uInt32 width, uInt32 height,
......@@ -50,7 +48,6 @@ FBSurfaceSDL2::FBSurfaceSDL2(FBBackendSDL2& backend,
: myBackend{backend},
myInterpolationMode{inter}
{
REF_COUNT++;
createSurface(width, height, staticData);
}
......@@ -61,8 +58,6 @@ FBSurfaceSDL2::~FBSurfaceSDL2()
if(mySurface)
{
REF_COUNT--;
cerr << " ~FBSurfaceSDL2(): " << this << " " << REF_COUNT << endl;
SDL_FreeSurface(mySurface);
mySurface = nullptr;
}
......
......@@ -67,7 +67,6 @@ FrameBuffer::FrameBuffer(OSystem& osystem)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FrameBuffer::~FrameBuffer()
{
cerr << "~FrameBuffer()" << endl << endl;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
......
......@@ -50,7 +50,8 @@ Dialog::Dialog(OSystem& instance, DialogContainer& parent, const GUI::Font& font
const string& title, int x, int y, int w, int h)
: GuiObject(instance, parent, *this, x, y, w, h),
_font{font},
_title{title}
_title{title},
_renderCallback{[]() { return; }}
{
_flags = Widget::FLAG_ENABLED | Widget::FLAG_BORDER | Widget::FLAG_CLEARBG;
setTitle(title);
......@@ -75,8 +76,6 @@ Dialog::~Dialog()
_firstWidget = nullptr;
_buttonGroup.clear();
cerr << "\n~Dialog(): " << this << endl;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
......@@ -163,6 +162,12 @@ void Dialog::setDirtyChain()
_dirtyChain = true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Dialog::resetSurfaces()
{
_surface->reload();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Dialog::tick()
{
......@@ -241,11 +246,7 @@ void Dialog::render()
// Update dialog surface; also render any extra surfaces
// Extra surfaces must be rendered afterwards, so they are drawn on top
if(_surface->render())
{
mySurfaceStack.applyAll([](unique_ptr<FBSurface>& surface) {
surface->render();
});
}
_renderCallback();
// A dialog is still on top if a non-shading dialog (e.g. ContextMenu)
// is opended above it.
......@@ -422,10 +423,9 @@ void Dialog::buildCurrentFocusList(int tabID)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Dialog::addSurface(const unique_ptr<FBSurface>& surface)
void Dialog::addRenderCallback(const std::function<void()>& callback)
{
// FIXME : add this to the stack somehow
// mySurfaceStack.push(surface);
_renderCallback = callback;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
......
......@@ -28,7 +28,6 @@ class TabWidget;
class CommandSender;
class ToolTip;
#include "Stack.hxx"
#include "Widget.hxx"
#include "GuiObject.hxx"
#include "StellaKeys.hxx"
......@@ -45,6 +44,8 @@ class Dialog : public GuiObject
friend class DialogContainer;
public:
using RenderCallback = std::function<void()>;
Dialog(OSystem& instance, DialogContainer& parent,
int x = 0, int y = 0, int w = 0, int h = 0);
Dialog(OSystem& instance, DialogContainer& parent, const GUI::Font& font,
......@@ -62,6 +63,8 @@ class Dialog : public GuiObject
virtual void saveConfig() { }
virtual void setDefaults() { }
virtual void resetSurfaces();
void setDirty() override;
void setDirtyChain() override;
void redraw(bool force = false);
......@@ -85,12 +88,11 @@ class Dialog : public GuiObject
FBSurface& surface() const { return *_surface; }
/**
Adds a surface to this dialog, which is rendered on top of the
base surface whenever the base surface is re-rendered. Since
the surface render() call will always occur in such a case, the
surface should call setVisible() to enable/disable its output.
This method is called each time the main Dialog::render is called.
It is called *after* the dialog has been rendered, so it can be
used to render another surface on top of it, among other things.
*/
void addSurface(const unique_ptr<FBSurface>& surface);
void addRenderCallback(const RenderCallback& callback);
void setTitle(const string& title);
bool hasTitle() { return !_title.empty(); }
......@@ -253,7 +255,7 @@ class Dialog : public GuiObject
uInt32 _max_w{0}; // maximum wanted width
uInt32 _max_h{0}; // maximum wanted height
Common::FixedStack<unique_ptr<FBSurface>> mySurfaceStack;
RenderCallback _renderCallback;
private:
// Following constructors and assignment operators not supported
......
......@@ -203,7 +203,7 @@ void DialogContainer::reStack()
void DialogContainer::resetSurfaces()
{
myDialogStack.applyAll([&](Dialog*& d) {
d->surface().reload();
d->resetSurfaces();
});
}
......
......@@ -350,6 +350,15 @@ void LauncherDialog::reload()
myPendingReload = false;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void LauncherDialog::resetSurfaces()
{
if(myRomInfoWidget)
myRomInfoWidget->resetSurfaces();
Dialog::resetSurfaces();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void LauncherDialog::tick()
{
......
......@@ -108,6 +108,7 @@ class LauncherDialog : public Dialog
void loadConfig() override;
void saveConfig() override;
void resetSurfaces() override;
void updateUI();
/**
......
......@@ -94,7 +94,11 @@ void RomInfoWidget::parseProperties(const FilesystemNode& node)
myAvail.w, myAvail.h, ScalingInterpolation::blur);
mySurface->applyAttributes();
dialog().addSurface(mySurface);
dialog().addRenderCallback([this]() {
if(mySurfaceIsValid)
mySurface->render();
}
);
}
// Initialize to empty properties entry
......@@ -169,6 +173,13 @@ void RomInfoWidget::parseProperties(const FilesystemNode& node)
setDirty();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void RomInfoWidget::resetSurfaces()
{
if(mySurface)
mySurface->reload();
}
#ifdef PNG_SUPPORT
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool RomInfoWidget::loadPng(const string& filename)
......
......@@ -39,6 +39,8 @@ class RomInfoWidget : public Widget
void clearProperties();
void reloadProperties(const FilesystemNode& node);
void resetSurfaces();
protected:
void drawWidget(bool hilite) override;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment