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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto prev_state = Core::GetState();
|
Core::RunAsCPUThread([&] {
|
||||||
Core::SetState(Core::State::Paused);
|
for (u32 i = 0; i < Memory::REALRAM_SIZE - GetTypeSize(); i++)
|
||||||
|
{
|
||||||
for (u32 i = 0; i < Memory::REALRAM_SIZE - GetTypeSize(); i++)
|
if (PowerPC::HostIsRAMAddress(base_address + i) && MatchesSearch(base_address + i))
|
||||||
{
|
m_results.push_back(
|
||||||
if (PowerPC::HostIsRAMAddress(base_address + i) && MatchesSearch(base_address + i))
|
{base_address + i, static_cast<DataType>(m_match_length->currentIndex())});
|
||||||
m_results.push_back(
|
}
|
||||||
{base_address + i, static_cast<DataType>(m_match_length->currentIndex())});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
Core::SetState(prev_state);
|
|
||||||
|
|
||||||
m_match_next->setEnabled(true);
|
m_match_next->setEnabled(true);
|
||||||
|
|
||||||
|
@ -451,17 +448,14 @@ void CheatsManager::NextSearch()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto prev_state = Core::GetState();
|
Core::RunAsCPUThread([this] {
|
||||||
Core::SetState(Core::State::Paused);
|
m_results.erase(std::remove_if(m_results.begin(), m_results.end(),
|
||||||
|
[this](Result r) {
|
||||||
m_results.erase(std::remove_if(m_results.begin(), m_results.end(),
|
return !PowerPC::HostIsRAMAddress(r.address) ||
|
||||||
[this](Result r) {
|
!MatchesSearch(r.address);
|
||||||
return !PowerPC::HostIsRAMAddress(r.address) ||
|
}),
|
||||||
!MatchesSearch(r.address);
|
m_results.end());
|
||||||
}),
|
});
|
||||||
m_results.end());
|
|
||||||
|
|
||||||
Core::SetState(prev_state);
|
|
||||||
|
|
||||||
Update();
|
Update();
|
||||||
}
|
}
|
||||||
|
@ -482,139 +476,134 @@ void CheatsManager::Update()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_updating = true;
|
|
||||||
|
|
||||||
m_result_label->setText(tr("%1 Match(es)").arg(m_results.size()));
|
m_result_label->setText(tr("%1 Match(es)").arg(m_results.size()));
|
||||||
m_match_table->setRowCount(static_cast<int>(m_results.size()));
|
m_match_table->setRowCount(static_cast<int>(m_results.size()));
|
||||||
|
|
||||||
for (size_t i = 0; i < m_results.size(); i++)
|
if (m_results.empty())
|
||||||
{
|
return;
|
||||||
auto* address_item = new QTableWidgetItem(
|
|
||||||
QStringLiteral("%1").arg(m_results[i].address, 8, 16, QLatin1Char('0')));
|
|
||||||
auto* value_item = new QTableWidgetItem;
|
|
||||||
|
|
||||||
address_item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
|
m_updating = true;
|
||||||
value_item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
|
|
||||||
|
|
||||||
if (PowerPC::HostIsRAMAddress(m_results[i].address))
|
Core::RunAsCPUThread([this] {
|
||||||
|
for (size_t i = 0; i < m_results.size(); i++)
|
||||||
{
|
{
|
||||||
const auto prev_state = Core::GetState();
|
auto* address_item = new QTableWidgetItem(
|
||||||
Core::SetState(Core::State::Paused);
|
QStringLiteral("%1").arg(m_results[i].address, 8, 16, QLatin1Char('0')));
|
||||||
|
auto* value_item = new QTableWidgetItem;
|
||||||
|
|
||||||
switch (m_results[i].type)
|
address_item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
|
||||||
|
value_item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
|
||||||
|
|
||||||
|
if (PowerPC::HostIsRAMAddress(m_results[i].address))
|
||||||
{
|
{
|
||||||
case DataType::Byte:
|
switch (m_results[i].type)
|
||||||
value_item->setText(QStringLiteral("%1").arg(PowerPC::HostRead_U8(m_results[i].address), 2,
|
{
|
||||||
16, QLatin1Char('0')));
|
case DataType::Byte:
|
||||||
break;
|
value_item->setText(QStringLiteral("%1").arg(PowerPC::HostRead_U8(m_results[i].address),
|
||||||
case DataType::Short:
|
2, 16, QLatin1Char('0')));
|
||||||
value_item->setText(QStringLiteral("%1").arg(PowerPC::HostRead_U16(m_results[i].address), 4,
|
break;
|
||||||
16, QLatin1Char('0')));
|
case DataType::Short:
|
||||||
break;
|
value_item->setText(QStringLiteral("%1").arg(PowerPC::HostRead_U16(m_results[i].address),
|
||||||
case DataType::Int:
|
4, 16, QLatin1Char('0')));
|
||||||
value_item->setText(QStringLiteral("%1").arg(PowerPC::HostRead_U32(m_results[i].address), 8,
|
break;
|
||||||
16, QLatin1Char('0')));
|
case DataType::Int:
|
||||||
break;
|
value_item->setText(QStringLiteral("%1").arg(PowerPC::HostRead_U32(m_results[i].address),
|
||||||
case DataType::Float:
|
8, 16, QLatin1Char('0')));
|
||||||
value_item->setText(QString::number(PowerPC::HostRead_F32(m_results[i].address)));
|
break;
|
||||||
break;
|
case DataType::Float:
|
||||||
case DataType::Double:
|
value_item->setText(QString::number(PowerPC::HostRead_F32(m_results[i].address)));
|
||||||
value_item->setText(QString::number(PowerPC::HostRead_F64(m_results[i].address)));
|
break;
|
||||||
break;
|
case DataType::Double:
|
||||||
case DataType::String:
|
value_item->setText(QString::number(PowerPC::HostRead_F64(m_results[i].address)));
|
||||||
value_item->setText(tr("String Match"));
|
break;
|
||||||
break;
|
case DataType::String:
|
||||||
|
value_item->setText(tr("String Match"));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
value_item->setText(QStringLiteral("---"));
|
||||||
}
|
}
|
||||||
|
|
||||||
Core::SetState(prev_state);
|
address_item->setData(INDEX_ROLE, static_cast<int>(i));
|
||||||
}
|
value_item->setData(INDEX_ROLE, static_cast<int>(i));
|
||||||
else
|
|
||||||
{
|
m_match_table->setItem(static_cast<int>(i), 0, address_item);
|
||||||
value_item->setText(QStringLiteral("---"));
|
m_match_table->setItem(static_cast<int>(i), 1, value_item);
|
||||||
}
|
}
|
||||||
|
|
||||||
address_item->setData(INDEX_ROLE, static_cast<int>(i));
|
m_watch_table->setRowCount(static_cast<int>(m_watch.size()));
|
||||||
value_item->setData(INDEX_ROLE, static_cast<int>(i));
|
|
||||||
|
|
||||||
m_match_table->setItem(static_cast<int>(i), 0, address_item);
|
for (size_t i = 0; i < m_watch.size(); i++)
|
||||||
m_match_table->setItem(static_cast<int>(i), 1, value_item);
|
|
||||||
}
|
|
||||||
|
|
||||||
m_watch_table->setRowCount(static_cast<int>(m_watch.size()));
|
|
||||||
|
|
||||||
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* lock_item = new QTableWidgetItem;
|
|
||||||
auto* value_item = new QTableWidgetItem;
|
|
||||||
|
|
||||||
if (PowerPC::HostIsRAMAddress(m_watch[i].address))
|
|
||||||
{
|
{
|
||||||
const auto prev_state = Core::GetState();
|
auto* name_item = new QTableWidgetItem(m_watch[i].name);
|
||||||
Core::SetState(Core::State::Paused);
|
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 (m_watch[i].locked)
|
if (PowerPC::HostIsRAMAddress(m_watch[i].address))
|
||||||
{
|
{
|
||||||
PowerPC::debug_interface.Patch(m_watch[i].address, m_watch[i].locked_value);
|
if (m_watch[i].locked)
|
||||||
|
{
|
||||||
|
PowerPC::debug_interface.Patch(m_watch[i].address, m_watch[i].locked_value);
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (m_watch[i].type)
|
||||||
|
{
|
||||||
|
case DataType::Byte:
|
||||||
|
value_item->setText(QStringLiteral("%1").arg(PowerPC::HostRead_U8(m_watch[i].address), 2,
|
||||||
|
16, QLatin1Char('0')));
|
||||||
|
break;
|
||||||
|
case DataType::Short:
|
||||||
|
value_item->setText(QStringLiteral("%1").arg(PowerPC::HostRead_U16(m_watch[i].address), 4,
|
||||||
|
16, QLatin1Char('0')));
|
||||||
|
break;
|
||||||
|
case DataType::Int:
|
||||||
|
value_item->setText(QStringLiteral("%1").arg(PowerPC::HostRead_U32(m_watch[i].address), 8,
|
||||||
|
16, QLatin1Char('0')));
|
||||||
|
break;
|
||||||
|
case DataType::Float:
|
||||||
|
value_item->setText(QString::number(PowerPC::HostRead_F32(m_watch[i].address)));
|
||||||
|
break;
|
||||||
|
case DataType::Double:
|
||||||
|
value_item->setText(QString::number(PowerPC::HostRead_F64(m_watch[i].address)));
|
||||||
|
break;
|
||||||
|
case DataType::String:
|
||||||
|
value_item->setText(tr("String Match"));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
value_item->setText(QStringLiteral("---"));
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (m_watch[i].type)
|
name_item->setData(INDEX_ROLE, static_cast<int>(i));
|
||||||
{
|
name_item->setData(COLUMN_ROLE, 0);
|
||||||
case DataType::Byte:
|
address_item->setData(INDEX_ROLE, static_cast<int>(i));
|
||||||
value_item->setText(QStringLiteral("%1").arg(PowerPC::HostRead_U8(m_watch[i].address), 2,
|
address_item->setData(COLUMN_ROLE, 1);
|
||||||
16, QLatin1Char('0')));
|
value_item->setData(INDEX_ROLE, static_cast<int>(i));
|
||||||
break;
|
value_item->setData(COLUMN_ROLE, 2);
|
||||||
case DataType::Short:
|
lock_item->setData(INDEX_ROLE, static_cast<int>(i));
|
||||||
value_item->setText(QStringLiteral("%1").arg(PowerPC::HostRead_U16(m_watch[i].address), 4,
|
lock_item->setData(COLUMN_ROLE, 3);
|
||||||
16, QLatin1Char('0')));
|
value_item->setData(INDEX_ROLE, static_cast<int>(i));
|
||||||
break;
|
value_item->setData(COLUMN_ROLE, 4);
|
||||||
case DataType::Int:
|
|
||||||
value_item->setText(QStringLiteral("%1").arg(PowerPC::HostRead_U32(m_watch[i].address), 8,
|
|
||||||
16, QLatin1Char('0')));
|
|
||||||
break;
|
|
||||||
case DataType::Float:
|
|
||||||
value_item->setText(QString::number(PowerPC::HostRead_F32(m_watch[i].address)));
|
|
||||||
break;
|
|
||||||
case DataType::Double:
|
|
||||||
value_item->setText(QString::number(PowerPC::HostRead_F64(m_watch[i].address)));
|
|
||||||
break;
|
|
||||||
case DataType::String:
|
|
||||||
value_item->setText(tr("String Match"));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
Core::SetState(prev_state);
|
name_item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable);
|
||||||
|
address_item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
|
||||||
|
lock_item->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsSelectable);
|
||||||
|
value_item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
|
||||||
|
|
||||||
|
lock_item->setCheckState(m_watch[i].locked ? Qt::Checked : Qt::Unchecked);
|
||||||
|
|
||||||
|
m_watch_table->setItem(static_cast<int>(i), 0, name_item);
|
||||||
|
m_watch_table->setItem(static_cast<int>(i), 1, address_item);
|
||||||
|
m_watch_table->setItem(static_cast<int>(i), 2, lock_item);
|
||||||
|
m_watch_table->setItem(static_cast<int>(i), 3, value_item);
|
||||||
}
|
}
|
||||||
else
|
});
|
||||||
{
|
|
||||||
value_item->setText(QStringLiteral("---"));
|
|
||||||
}
|
|
||||||
|
|
||||||
name_item->setData(INDEX_ROLE, static_cast<int>(i));
|
|
||||||
name_item->setData(COLUMN_ROLE, 0);
|
|
||||||
address_item->setData(INDEX_ROLE, static_cast<int>(i));
|
|
||||||
address_item->setData(COLUMN_ROLE, 1);
|
|
||||||
value_item->setData(INDEX_ROLE, static_cast<int>(i));
|
|
||||||
value_item->setData(COLUMN_ROLE, 2);
|
|
||||||
lock_item->setData(INDEX_ROLE, static_cast<int>(i));
|
|
||||||
lock_item->setData(COLUMN_ROLE, 3);
|
|
||||||
value_item->setData(INDEX_ROLE, static_cast<int>(i));
|
|
||||||
value_item->setData(COLUMN_ROLE, 4);
|
|
||||||
|
|
||||||
name_item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable);
|
|
||||||
address_item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
|
|
||||||
lock_item->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsSelectable);
|
|
||||||
value_item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
|
|
||||||
|
|
||||||
lock_item->setCheckState(m_watch[i].locked ? Qt::Checked : Qt::Unchecked);
|
|
||||||
|
|
||||||
m_watch_table->setItem(static_cast<int>(i), 0, name_item);
|
|
||||||
m_watch_table->setItem(static_cast<int>(i), 1, address_item);
|
|
||||||
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;
|
m_updating = false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue