CheatsManager/CheatSearchWidget: Avoid Global System Accessor
OnResetClicked and GenerateARCode appear to have been using the CPUThreadGuard in error.
This commit is contained in:
parent
551dcec0b1
commit
c377c1e21e
|
@ -54,8 +54,10 @@ constexpr int ADDRESS_TABLE_COLUMN_INDEX_ADDRESS = 1;
|
|||
constexpr int ADDRESS_TABLE_COLUMN_INDEX_LAST_VALUE = 2;
|
||||
constexpr int ADDRESS_TABLE_COLUMN_INDEX_CURRENT_VALUE = 3;
|
||||
|
||||
CheatSearchWidget::CheatSearchWidget(std::unique_ptr<Cheats::CheatSearchSessionBase> session)
|
||||
: m_session(std::move(session))
|
||||
CheatSearchWidget::CheatSearchWidget(Core::System& system,
|
||||
std::unique_ptr<Cheats::CheatSearchSessionBase> session,
|
||||
QWidget* parent)
|
||||
: QWidget(parent), m_system(system), m_session(std::move(session))
|
||||
{
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
CreateWidgets();
|
||||
|
@ -275,13 +277,10 @@ void CheatSearchWidget::ConnectWidgets()
|
|||
|
||||
void CheatSearchWidget::OnNextScanClicked()
|
||||
{
|
||||
Core::CPUThreadGuard guard(Core::System::GetInstance());
|
||||
const bool had_old_results = m_session->WasFirstSearchDone();
|
||||
const size_t old_count = m_session->GetResultCount();
|
||||
|
||||
const auto filter_type = m_value_source_dropdown->currentData().value<Cheats::FilterType>();
|
||||
if (filter_type == Cheats::FilterType::CompareAgainstLastValue &&
|
||||
!m_session->WasFirstSearchDone())
|
||||
if (filter_type == Cheats::FilterType::CompareAgainstLastValue && !had_old_results)
|
||||
{
|
||||
m_info_label_1->setText(tr("Cannot compare against last value on first search."));
|
||||
return;
|
||||
|
@ -301,7 +300,8 @@ void CheatSearchWidget::OnNextScanClicked()
|
|||
}
|
||||
}
|
||||
|
||||
const Cheats::SearchErrorCode error_code = m_session->RunSearch(guard);
|
||||
const size_t old_count = m_session->GetResultCount();
|
||||
const Cheats::SearchErrorCode error_code = m_session->RunSearch(Core::CPUThreadGuard{m_system});
|
||||
|
||||
if (error_code == Cheats::SearchErrorCode::Success)
|
||||
{
|
||||
|
@ -416,11 +416,11 @@ void CheatSearchWidget::UpdateTableVisibleCurrentValues(const UpdateSource sourc
|
|||
if (source == UpdateSource::Auto && !m_autoupdate_current_values->isChecked())
|
||||
return;
|
||||
|
||||
Core::CPUThreadGuard guard(Core::System::GetInstance());
|
||||
if (m_address_table->rowCount() == 0)
|
||||
return;
|
||||
|
||||
UpdateTableRows(guard, GetVisibleRowsBeginIndex(), GetVisibleRowsEndIndex(), source);
|
||||
UpdateTableRows(Core::CPUThreadGuard{m_system}, GetVisibleRowsBeginIndex(),
|
||||
GetVisibleRowsEndIndex(), source);
|
||||
}
|
||||
|
||||
bool CheatSearchWidget::UpdateTableAllCurrentValues(const UpdateSource source)
|
||||
|
@ -428,7 +428,6 @@ bool CheatSearchWidget::UpdateTableAllCurrentValues(const UpdateSource source)
|
|||
if (source == UpdateSource::Auto && !m_autoupdate_current_values->isChecked())
|
||||
return false;
|
||||
|
||||
Core::CPUThreadGuard guard(Core::System::GetInstance());
|
||||
const size_t result_count = m_address_table->rowCount();
|
||||
if (result_count == 0)
|
||||
{
|
||||
|
@ -437,7 +436,7 @@ bool CheatSearchWidget::UpdateTableAllCurrentValues(const UpdateSource source)
|
|||
return false;
|
||||
}
|
||||
|
||||
return UpdateTableRows(guard, 0, result_count, source);
|
||||
return UpdateTableRows(Core::CPUThreadGuard{m_system}, 0, result_count, source);
|
||||
}
|
||||
|
||||
void CheatSearchWidget::OnRefreshClicked()
|
||||
|
@ -447,7 +446,6 @@ void CheatSearchWidget::OnRefreshClicked()
|
|||
|
||||
void CheatSearchWidget::OnResetClicked()
|
||||
{
|
||||
Core::CPUThreadGuard guard(Core::System::GetInstance());
|
||||
m_session->ResetResults();
|
||||
m_address_table_current_values.clear();
|
||||
|
||||
|
@ -525,7 +523,6 @@ void CheatSearchWidget::OnDisplayHexCheckboxStateChanged()
|
|||
|
||||
void CheatSearchWidget::GenerateARCode()
|
||||
{
|
||||
Core::CPUThreadGuard guard(Core::System::GetInstance());
|
||||
if (m_address_table->selectedItems().isEmpty())
|
||||
return;
|
||||
|
||||
|
|
|
@ -18,6 +18,10 @@ namespace ActionReplay
|
|||
{
|
||||
struct ARCode;
|
||||
}
|
||||
namespace Core
|
||||
{
|
||||
class System;
|
||||
}
|
||||
|
||||
class QCheckBox;
|
||||
class QComboBox;
|
||||
|
@ -36,7 +40,9 @@ class CheatSearchWidget : public QWidget
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit CheatSearchWidget(std::unique_ptr<Cheats::CheatSearchSessionBase> session);
|
||||
explicit CheatSearchWidget(Core::System& system,
|
||||
std::unique_ptr<Cheats::CheatSearchSessionBase> session,
|
||||
QWidget* parent = nullptr);
|
||||
~CheatSearchWidget() override;
|
||||
|
||||
enum class UpdateSource
|
||||
|
@ -74,6 +80,8 @@ private:
|
|||
int GetVisibleRowsBeginIndex() const;
|
||||
int GetVisibleRowsEndIndex() const;
|
||||
|
||||
Core::System& m_system;
|
||||
|
||||
std::unique_ptr<Cheats::CheatSearchSessionBase> m_session;
|
||||
|
||||
// storage for the 'Current Value' column's data
|
||||
|
|
|
@ -24,7 +24,8 @@
|
|||
|
||||
#include "VideoCommon/VideoEvents.h"
|
||||
|
||||
CheatsManager::CheatsManager(QWidget* parent) : QDialog(parent)
|
||||
CheatsManager::CheatsManager(Core::System& system, QWidget* parent)
|
||||
: QDialog(parent), m_system(system)
|
||||
{
|
||||
setWindowTitle(tr("Cheats Manager"));
|
||||
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||
|
@ -169,7 +170,7 @@ void CheatsManager::CreateWidgets()
|
|||
|
||||
void CheatsManager::OnNewSessionCreated(const Cheats::CheatSearchSessionBase& session)
|
||||
{
|
||||
auto* w = new CheatSearchWidget(session.Clone());
|
||||
auto* w = new CheatSearchWidget(m_system, session.Clone());
|
||||
const int tab_index = m_tab_widget->addTab(w, tr("Cheat Search"));
|
||||
w->connect(w, &CheatSearchWidget::ActionReplayCodeGenerated, this,
|
||||
[this](const ActionReplay::ARCode& ar_code) {
|
||||
|
|
|
@ -26,13 +26,14 @@ class PartiallyClosableTabWidget;
|
|||
namespace Core
|
||||
{
|
||||
enum class State;
|
||||
}
|
||||
class System;
|
||||
} // namespace Core
|
||||
|
||||
class CheatsManager : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit CheatsManager(QWidget* parent = nullptr);
|
||||
explicit CheatsManager(Core::System& system, QWidget* parent = nullptr);
|
||||
~CheatsManager();
|
||||
|
||||
signals:
|
||||
|
@ -64,6 +65,8 @@ private:
|
|||
std::string m_game_tdb_id;
|
||||
u16 m_revision = 0;
|
||||
|
||||
Core::System& m_system;
|
||||
|
||||
QDialogButtonBox* m_button_box;
|
||||
PartiallyClosableTabWidget* m_tab_widget = nullptr;
|
||||
|
||||
|
|
|
@ -456,7 +456,7 @@ void MainWindow::CreateComponents()
|
|||
m_watch_widget = new WatchWidget(this);
|
||||
m_breakpoint_widget = new BreakpointWidget(this);
|
||||
m_code_widget = new CodeWidget(this);
|
||||
m_cheats_manager = new CheatsManager(this);
|
||||
m_cheats_manager = new CheatsManager(Core::System::GetInstance(), this);
|
||||
m_assembler_widget = new AssemblerWidget(this);
|
||||
|
||||
const auto request_watch = [this](QString name, u32 addr) {
|
||||
|
|
Loading…
Reference in New Issue