Fix loading of ROM twice on each selection in the ROM launcher.

It was being opened once for the snapshots, and again for the controllers.
This commit is contained in:
Stephen Anthony 2020-04-23 14:14:59 -02:30
parent 2938ca2fc6
commit becc72e3ea
3 changed files with 16 additions and 22 deletions

View File

@ -428,13 +428,7 @@ void LauncherDialog::loadRomInfo()
const string& md5 = selectedRomMD5();
if(md5 != EmptyString)
{
// Get the properties for this entry
Properties props;
instance().propSet().getMD5WithInsert(currentNode(), md5, props);
myRomInfoWidget->setProperties(props, currentNode());
}
myRomInfoWidget->setProperties(currentNode(), md5);
else
myRomInfoWidget->clearProperties();
}

View File

@ -27,6 +27,7 @@
#include "Logger.hxx"
#include "Props.hxx"
#include "PNGLibrary.hxx"
#include "PropsSet.hxx"
#include "Rect.hxx"
#include "Widget.hxx"
#include "RomInfoWidget.hxx"
@ -44,20 +45,10 @@ RomInfoWidget::RomInfoWidget(GuiObject* boss, const GUI::Font& font,
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void RomInfoWidget::reloadProperties(const FilesystemNode& node)
{
// The ROM may have changed since we were last in the browser, either
// by saving a different image or through a change in video renderer,
// so we reload the properties
if(myHaveProperties)
parseProperties(node);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void RomInfoWidget::setProperties(const Properties& props, const FilesystemNode& node)
void RomInfoWidget::setProperties(const FilesystemNode& node, const string& md5)
{
myHaveProperties = true;
myProperties = props;
instance().propSet().getMD5(md5, myProperties);
// Decide whether the information should be shown immediately
if(instance().eventHandler().state() == EventHandlerState::LAUNCHER)
@ -76,6 +67,16 @@ void RomInfoWidget::clearProperties()
setDirty();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void RomInfoWidget::reloadProperties(const FilesystemNode& node)
{
// The ROM may have changed since we were last in the browser, either
// by saving a different image or through a change in video renderer,
// so we reload the properties
if(myHaveProperties)
parseProperties(node);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void RomInfoWidget::parseProperties(const FilesystemNode& node)
{
@ -140,8 +141,7 @@ void RomInfoWidget::parseProperties(const FilesystemNode& node)
try
{
ByteBuffer image;
string md5 = myProperties.get(PropType::Cart_MD5);
size_t size = 0;
string md5 = ""; size_t size = 0;
if(node.exists() && !node.isDirectory() &&
(image = instance().openROM(node, md5, size)) != nullptr)

View File

@ -35,7 +35,7 @@ class RomInfoWidget : public Widget
const Common::Size& imgSize);
virtual ~RomInfoWidget() = default;
void setProperties(const Properties& props, const FilesystemNode& node);
void setProperties(const FilesystemNode& node, const string& md5);
void clearProperties();
void reloadProperties(const FilesystemNode& node);