forked from mirror/OpenTTD
Codechange: use RAII to automatically restore _cur_dpi after use
This commit is contained in:
@@ -363,8 +363,7 @@ public:
|
||||
DrawPixelInfo tmp_dpi;
|
||||
/* Set up a clipping area for the preview. */
|
||||
if (FillDrawPixelInfo(&tmp_dpi, r.left, r.top, r.Width(), r.Height())) {
|
||||
DrawPixelInfo *old_dpi = _cur_dpi;
|
||||
_cur_dpi = &tmp_dpi;
|
||||
AutoRestoreBackup dpi_backup(_cur_dpi, &tmp_dpi);
|
||||
if (spec->grf_prop.grffile == nullptr) {
|
||||
extern const DrawTileSprites _objects[];
|
||||
const DrawTileSprites *dts = &_objects[spec->grf_prop.local_id];
|
||||
@@ -372,7 +371,6 @@ public:
|
||||
} else {
|
||||
DrawNewObjectTileInGUI(r.Width() / 2 - 1, (r.Height() + matrix_height / 2) / 2 - this->object_margin - ScaleSpriteTrad(TILE_PIXELS), spec, GB(widget, 16, 16));
|
||||
}
|
||||
_cur_dpi = old_dpi;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -390,8 +388,7 @@ public:
|
||||
DrawPixelInfo tmp_dpi;
|
||||
/* Set up a clipping area for the preview. */
|
||||
if (FillDrawPixelInfo(&tmp_dpi, r.left, r.top, r.Width(), r.Height())) {
|
||||
DrawPixelInfo *old_dpi = _cur_dpi;
|
||||
_cur_dpi = &tmp_dpi;
|
||||
AutoRestoreBackup dpi_backup(_cur_dpi, &tmp_dpi);
|
||||
if (spec->grf_prop.grffile == nullptr) {
|
||||
extern const DrawTileSprites _objects[];
|
||||
const DrawTileSprites *dts = &_objects[spec->grf_prop.local_id];
|
||||
@@ -400,7 +397,6 @@ public:
|
||||
DrawNewObjectTileInGUI(r.Width() / 2 - 1, r.Height() - this->object_margin - ScaleSpriteTrad(TILE_PIXELS), spec,
|
||||
std::min<int>(_selected_object_view, spec->views - 1));
|
||||
}
|
||||
_cur_dpi = old_dpi;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
Reference in New Issue
Block a user