Only change modes when the lock is being held, see 2333786 (fixes #700)

This commit is contained in:
Tamás Bálint Misius 2020-03-23 23:08:34 +01:00
parent 21b9e1a645
commit fe15566d2c
No known key found for this signature in database
GPG Key ID: 5B472A12F6ECA9F2
5 changed files with 11 additions and 20 deletions

View File

@ -22,7 +22,6 @@ ThumbnailRendererTask::~ThumbnailRendererTask()
bool ThumbnailRendererTask::doWork()
{
SaveRenderer::Ref().ResetModes();
thumbnail = std::unique_ptr<VideoBuffer>(SaveRenderer::Ref().Render(Save.get(), Decorations, Fire));
if (thumbnail)
{

View File

@ -1784,8 +1784,7 @@ void GameView::NotifyPlaceSaveChanged(GameModel * sender)
placeSaveOffset = ui::Point(0, 0);
if(sender->GetPlaceSave())
{
SaveRenderer::Ref().CopyModes(sender->GetRenderer());
placeSaveThumb = SaveRenderer::Ref().Render(sender->GetPlaceSave());
placeSaveThumb = SaveRenderer::Ref().Render(sender->GetPlaceSave(), true, true, sender->GetRenderer());
selectMode = PlaceSave;
selectPoint2 = mousePosition;
}

View File

@ -460,7 +460,6 @@ void PreviewView::NotifySaveChanged(PreviewModel * sender)
if(save->GetGameSave())
{
SaveRenderer::Ref().ResetModes();
savePreview = SaveRenderer::Ref().Render(save->GetGameSave(), false, true);
if(savePreview && savePreview->Buffer && !(savePreview->Width == XRES/2 && savePreview->Height == YRES/2))

View File

@ -33,10 +33,18 @@ SaveRenderer::SaveRenderer(){
#endif
}
VideoBuffer * SaveRenderer::Render(GameSave * save, bool decorations, bool fire)
VideoBuffer * SaveRenderer::Render(GameSave * save, bool decorations, bool fire, Renderer *renderModeSource)
{
std::lock_guard<std::mutex> gx(renderMutex);
ren->ResetModes();
if (renderModeSource)
{
ren->SetRenderMode(renderModeSource->GetRenderMode());
ren->SetDisplayMode(renderModeSource->GetDisplayMode());
ren->SetColourMode(renderModeSource->GetColourMode());
}
int width, height;
VideoBuffer * tempThumb = NULL;
width = save->blockWidth;
@ -175,15 +183,3 @@ VideoBuffer * SaveRenderer::Render(unsigned char * saveData, int dataSize, bool
SaveRenderer::~SaveRenderer()
{
}
void SaveRenderer::CopyModes(Renderer *source)
{
ren->SetRenderMode(source->GetRenderMode());
ren->SetDisplayMode(source->GetDisplayMode());
ren->SetColourMode(source->GetColourMode());
}
void SaveRenderer::ResetModes()
{
ren->ResetModes();
}

View File

@ -19,10 +19,8 @@ class SaveRenderer: public Singleton<SaveRenderer> {
std::mutex renderMutex;
public:
SaveRenderer();
VideoBuffer * Render(GameSave * save, bool decorations = true, bool fire = true);
VideoBuffer * Render(GameSave * save, bool decorations = true, bool fire = true, Renderer *renderModeSource = nullptr);
VideoBuffer * Render(unsigned char * saveData, int saveDataSize, bool decorations = true, bool fire = true);
void CopyModes(Renderer *source);
void ResetModes();
virtual ~SaveRenderer();
private: