Codechange: use RAII to automatically restore _cur_dpi after use
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
/** @file screenshot.cpp The creation of screenshots! */
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "core/backup_type.hpp"
|
||||
#include "fileio_func.h"
|
||||
#include "viewport_func.h"
|
||||
#include "gfx_func.h"
|
||||
@@ -617,7 +618,7 @@ static void CurrentScreenCallback(void *userdata, void *buf, uint y, uint pitch,
|
||||
static void LargeWorldCallback(void *userdata, void *buf, uint y, uint pitch, uint n)
|
||||
{
|
||||
Viewport *vp = (Viewport *)userdata;
|
||||
DrawPixelInfo dpi, *old_dpi;
|
||||
DrawPixelInfo dpi;
|
||||
int wx, left;
|
||||
|
||||
/* We are no longer rendering to the screen */
|
||||
@@ -630,8 +631,7 @@ static void LargeWorldCallback(void *userdata, void *buf, uint y, uint pitch, ui
|
||||
_screen.pitch = pitch;
|
||||
_screen_disable_anim = true;
|
||||
|
||||
old_dpi = _cur_dpi;
|
||||
_cur_dpi = &dpi;
|
||||
AutoRestoreBackup dpi_backup(_cur_dpi, &dpi);
|
||||
|
||||
dpi.dst_ptr = buf;
|
||||
dpi.height = n;
|
||||
@@ -655,8 +655,6 @@ static void LargeWorldCallback(void *userdata, void *buf, uint y, uint pitch, ui
|
||||
);
|
||||
}
|
||||
|
||||
_cur_dpi = old_dpi;
|
||||
|
||||
/* Switch back to rendering to the screen */
|
||||
_screen = old_screen;
|
||||
_screen_disable_anim = old_disable_anim;
|
||||
|
Reference in New Issue
Block a user