Qt/CheatsManager: Fix updating search result takes a long time
This commit is contained in:
parent
0cd46f4d21
commit
850afd8457
|
@ -426,17 +426,14 @@ void CheatsManager::NewSearch()
|
|||
return;
|
||||
}
|
||||
|
||||
const auto prev_state = Core::GetState();
|
||||
Core::SetState(Core::State::Paused);
|
||||
|
||||
Core::RunAsCPUThread([&] {
|
||||
for (u32 i = 0; i < Memory::REALRAM_SIZE - GetTypeSize(); i++)
|
||||
{
|
||||
if (PowerPC::HostIsRAMAddress(base_address + i) && MatchesSearch(base_address + i))
|
||||
m_results.push_back(
|
||||
{base_address + i, static_cast<DataType>(m_match_length->currentIndex())});
|
||||
}
|
||||
|
||||
Core::SetState(prev_state);
|
||||
});
|
||||
|
||||
m_match_next->setEnabled(true);
|
||||
|
||||
|
@ -451,17 +448,14 @@ void CheatsManager::NextSearch()
|
|||
return;
|
||||
}
|
||||
|
||||
const auto prev_state = Core::GetState();
|
||||
Core::SetState(Core::State::Paused);
|
||||
|
||||
Core::RunAsCPUThread([this] {
|
||||
m_results.erase(std::remove_if(m_results.begin(), m_results.end(),
|
||||
[this](Result r) {
|
||||
return !PowerPC::HostIsRAMAddress(r.address) ||
|
||||
!MatchesSearch(r.address);
|
||||
}),
|
||||
m_results.end());
|
||||
|
||||
Core::SetState(prev_state);
|
||||
});
|
||||
|
||||
Update();
|
||||
}
|
||||
|
@ -482,11 +476,15 @@ void CheatsManager::Update()
|
|||
return;
|
||||
}
|
||||
|
||||
m_updating = true;
|
||||
|
||||
m_result_label->setText(tr("%1 Match(es)").arg(m_results.size()));
|
||||
m_match_table->setRowCount(static_cast<int>(m_results.size()));
|
||||
|
||||
if (m_results.empty())
|
||||
return;
|
||||
|
||||
m_updating = true;
|
||||
|
||||
Core::RunAsCPUThread([this] {
|
||||
for (size_t i = 0; i < m_results.size(); i++)
|
||||
{
|
||||
auto* address_item = new QTableWidgetItem(
|
||||
|
@ -498,22 +496,19 @@ void CheatsManager::Update()
|
|||
|
||||
if (PowerPC::HostIsRAMAddress(m_results[i].address))
|
||||
{
|
||||
const auto prev_state = Core::GetState();
|
||||
Core::SetState(Core::State::Paused);
|
||||
|
||||
switch (m_results[i].type)
|
||||
{
|
||||
case DataType::Byte:
|
||||
value_item->setText(QStringLiteral("%1").arg(PowerPC::HostRead_U8(m_results[i].address), 2,
|
||||
16, QLatin1Char('0')));
|
||||
value_item->setText(QStringLiteral("%1").arg(PowerPC::HostRead_U8(m_results[i].address),
|
||||
2, 16, QLatin1Char('0')));
|
||||
break;
|
||||
case DataType::Short:
|
||||
value_item->setText(QStringLiteral("%1").arg(PowerPC::HostRead_U16(m_results[i].address), 4,
|
||||
16, QLatin1Char('0')));
|
||||
value_item->setText(QStringLiteral("%1").arg(PowerPC::HostRead_U16(m_results[i].address),
|
||||
4, 16, QLatin1Char('0')));
|
||||
break;
|
||||
case DataType::Int:
|
||||
value_item->setText(QStringLiteral("%1").arg(PowerPC::HostRead_U32(m_results[i].address), 8,
|
||||
16, QLatin1Char('0')));
|
||||
value_item->setText(QStringLiteral("%1").arg(PowerPC::HostRead_U32(m_results[i].address),
|
||||
8, 16, QLatin1Char('0')));
|
||||
break;
|
||||
case DataType::Float:
|
||||
value_item->setText(QString::number(PowerPC::HostRead_F32(m_results[i].address)));
|
||||
|
@ -525,8 +520,6 @@ void CheatsManager::Update()
|
|||
value_item->setText(tr("String Match"));
|
||||
break;
|
||||
}
|
||||
|
||||
Core::SetState(prev_state);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -545,16 +538,13 @@ void CheatsManager::Update()
|
|||
for (size_t i = 0; i < m_watch.size(); i++)
|
||||
{
|
||||
auto* name_item = new QTableWidgetItem(m_watch[i].name);
|
||||
auto* address_item =
|
||||
new QTableWidgetItem(QStringLiteral("%1").arg(m_watch[i].address, 8, 16, QLatin1Char('0')));
|
||||
auto* address_item = new QTableWidgetItem(
|
||||
QStringLiteral("%1").arg(m_watch[i].address, 8, 16, QLatin1Char('0')));
|
||||
auto* lock_item = new QTableWidgetItem;
|
||||
auto* value_item = new QTableWidgetItem;
|
||||
|
||||
if (PowerPC::HostIsRAMAddress(m_watch[i].address))
|
||||
{
|
||||
const auto prev_state = Core::GetState();
|
||||
Core::SetState(Core::State::Paused);
|
||||
|
||||
if (m_watch[i].locked)
|
||||
{
|
||||
PowerPC::debug_interface.Patch(m_watch[i].address, m_watch[i].locked_value);
|
||||
|
@ -584,8 +574,6 @@ void CheatsManager::Update()
|
|||
value_item->setText(tr("String Match"));
|
||||
break;
|
||||
}
|
||||
|
||||
Core::SetState(prev_state);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -615,6 +603,7 @@ void CheatsManager::Update()
|
|||
m_watch_table->setItem(static_cast<int>(i), 2, lock_item);
|
||||
m_watch_table->setItem(static_cast<int>(i), 3, value_item);
|
||||
}
|
||||
});
|
||||
|
||||
m_updating = false;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue