Move variables to inner scope

This commit is contained in:
tygyh 2024-11-15 09:15:06 +01:00 committed by Dr. Dystopia
parent 2c92e5b5b3
commit 04bc072627
7 changed files with 13 additions and 18 deletions

View File

@ -332,9 +332,9 @@ void EnhancementsWidget::LoadPPShaders(StereoMode stereo_mode)
tr("%1 doesn't support this feature.")
.arg(tr(g_video_backend->GetDisplayName().c_str())));
VideoCommon::PostProcessingConfiguration pp_shader;
if (selected_shader != "" && supports_postprocessing)
{
VideoCommon::PostProcessingConfiguration pp_shader;
pp_shader.LoadShader(selected_shader);
m_configure_pp_effect->setEnabled(pp_shader.HasOptions());
}
@ -513,9 +513,9 @@ void EnhancementsWidget::SaveSettings()
"" :
m_pp_effect->currentText().toStdString());
VideoCommon::PostProcessingConfiguration pp_shader;
if (Config::Get(Config::GFX_ENHANCE_POST_SHADER) != "")
{
VideoCommon::PostProcessingConfiguration pp_shader;
pp_shader.LoadShader(Config::Get(Config::GFX_ENHANCE_POST_SHADER));
m_configure_pp_effect->setEnabled(pp_shader.HasOptions());
}

View File

@ -71,10 +71,10 @@ private:
painter->setClipRect(option.rect);
painter->setPen(m_parent->palette().text().color());
constexpr u32 x_offset_in_branch_for_vertical_line = 10;
const u32 addr = m_parent->AddressForRow(index.row());
for (const CodeViewBranch& branch : m_parent->m_branches)
{
constexpr u32 x_offset_in_branch_for_vertical_line = 10;
const int y_center = option.rect.top() + option.rect.height() / 2;
const int x_left = option.rect.left() + WIDTH_PER_BRANCH_ARROW * branch.indentation;
const int x_right = x_left + x_offset_in_branch_for_vertical_line;

View File

@ -519,8 +519,8 @@ void CodeWidget::StepOut()
clock::time_point timeout = clock::now() + std::chrono::seconds(5);
auto& power_pc = m_system.GetPowerPC();
auto& ppc_state = power_pc.GetPPCState();
{
auto& ppc_state = power_pc.GetPPCState();
Core::CPUThreadGuard guard(m_system);
PowerPC::CoreMode old_mode = power_pc.GetMode();

View File

@ -186,12 +186,11 @@ void GameList::MakeListView()
if (!Settings::GetQSettings().contains(QStringLiteral("tableheader/state")))
m_list->sortByColumn(static_cast<int>(GameListModel::Column::Title), Qt::AscendingOrder);
const auto SetResizeMode = [&hor_header](const GameListModel::Column column,
const QHeaderView::ResizeMode mode) {
hor_header->setSectionResizeMode(static_cast<int>(column), mode);
};
{
const auto SetResizeMode = [&hor_header](const GameListModel::Column column,
const QHeaderView::ResizeMode mode) {
hor_header->setSectionResizeMode(static_cast<int>(column), mode);
};
using Column = GameListModel::Column;
using Mode = QHeaderView::ResizeMode;
SetResizeMode(Column::Platform, Mode::Fixed);
@ -1021,8 +1020,6 @@ void GameList::OnSectionResized(int index, int, int)
{
auto* hor_header = m_list->horizontalHeader();
std::vector<int> sections;
const int vis_index = hor_header->visualIndex(index);
const int col_count = hor_header->count() - hor_header->hiddenSectionCount();
@ -1040,6 +1037,7 @@ void GameList::OnSectionResized(int index, int, int)
if (!last)
{
std::vector<int> sections;
for (int i = 0; i < vis_index; i++)
{
const int logical_index = hor_header->logicalIndex(i);

View File

@ -106,13 +106,12 @@ QVariant GameListModel::data(const QModelIndex& index, int role) const
// For natural sorting, pad all numbers to the same length.
if (SORT_ROLE == role)
{
constexpr int MAX_NUMBER_LENGTH = 10;
const QRegularExpression rx(QStringLiteral("\\d+"));
QRegularExpressionMatch match;
int pos = 0;
while ((match = rx.match(name, pos)).hasMatch())
{
constexpr int MAX_NUMBER_LENGTH = 10;
pos = match.capturedStart();
name.replace(pos, match.capturedLength(),
match.captured().rightJustified(MAX_NUMBER_LENGTH));

View File

@ -80,9 +80,6 @@ static bool IsHotkey(int id, bool held = false)
static void HandleFrameStepHotkeys()
{
constexpr int MAX_FRAME_STEP_DELAY = 60;
constexpr int FRAME_STEP_DELAY = 30;
static int frame_step_count = 0;
static int frame_step_delay = 1;
static int frame_step_delay_count = 0;
@ -96,6 +93,7 @@ static void HandleFrameStepHotkeys()
if (IsHotkey(HK_FRAME_ADVANCE_DECREASE_SPEED))
{
constexpr int MAX_FRAME_STEP_DELAY = 60;
frame_step_delay = std::min(frame_step_delay + 1, MAX_FRAME_STEP_DELAY);
return;
}
@ -108,6 +106,7 @@ static void HandleFrameStepHotkeys()
if (IsHotkey(HK_FRAME_ADVANCE, true))
{
constexpr int FRAME_STEP_DELAY = 30;
if (frame_step_delay_count < frame_step_delay && frame_step_hold)
frame_step_delay_count++;

View File

@ -530,11 +530,10 @@ void RenderWidget::PassEventToPresenter(const QEvent* event)
const u32 key = static_cast<u32>(key_event->key() & 0x1FF);
const char* chars = nullptr;
QByteArray utf8;
if (is_down)
{
utf8 = key_event->text().toUtf8();
QByteArray utf8 = key_event->text().toUtf8();
if (utf8.size())
chars = utf8.constData();