Codechange: use RAII to automatically restore _cur_dpi after use

This commit is contained in:
Rubidium
2023-01-26 19:21:36 +01:00
committed by rubidium42
parent b7a5d8e296
commit f001e84e5e
18 changed files with 122 additions and 136 deletions

View File

@@ -820,8 +820,7 @@ void QueryString::DrawEditBox(const Window *w, int wid) const
DrawPixelInfo dpi;
if (!FillDrawPixelInfo(&dpi, fr.left, fr.top, fr.Width(), fr.Height())) return;
DrawPixelInfo *old_dpi = _cur_dpi;
_cur_dpi = &dpi;
AutoRestoreBackup dpi_backup(_cur_dpi, &dpi);
/* We will take the current widget length as maximum width, with a small
* space reserved at the end for the caret to show */
@@ -839,8 +838,6 @@ void QueryString::DrawEditBox(const Window *w, int wid) const
int caret_width = GetStringBoundingBox("_").width;
DrawString(tb->caretxoffs + delta, tb->caretxoffs + delta + caret_width, 0, "_", TC_WHITE);
}
_cur_dpi = old_dpi;
}
/**