Qt: Pass QStrings by reference in HostInterface

This commit is contained in:
Connor McLaughlin 2020-02-16 00:14:30 +09:00
parent fd8ed08307
commit e5740a5632
4 changed files with 17 additions and 17 deletions

View File

@ -33,12 +33,12 @@ MainWindow::~MainWindow()
Assert(!m_display_widget);
}
void MainWindow::reportError(QString message)
void MainWindow::reportError(const QString& message)
{
QMessageBox::critical(nullptr, tr("DuckStation Error"), message, QMessageBox::Ok);
}
void MainWindow::reportMessage(QString message)
void MainWindow::reportMessage(const QString& message)
{
m_ui.statusBar->showMessage(message, 2000);
}
@ -129,7 +129,7 @@ void MainWindow::onSystemPerformanceCountersUpdated(float speed, float fps, floa
QStringLiteral("%1ms average, %2ms worst").arg(average_frame_time, 0, 'f', 2).arg(worst_frame_time, 0, 'f', 2));
}
void MainWindow::onRunningGameChanged(QString filename, QString game_code, QString game_title)
void MainWindow::onRunningGameChanged(const QString& filename, const QString& game_code, const QString& game_title)
{
m_host_interface->populateSaveStateMenus(game_code.toStdString().c_str(), m_ui.menuLoadState, m_ui.menuSaveState);
if (game_title.isEmpty())

View File

@ -22,8 +22,8 @@ public:
~MainWindow();
private Q_SLOTS:
void reportError(QString message);
void reportMessage(QString message);
void reportError(const QString& message);
void reportMessage(const QString& message);
void createDisplayWindow(QThread* worker_thread, bool use_debug_device);
void destroyDisplayWindow();
void toggleFullscreen();
@ -32,7 +32,7 @@ private Q_SLOTS:
void onEmulationPaused(bool paused);
void onSystemPerformanceCountersUpdated(float speed, float fps, float vps, float average_frame_time,
float worst_frame_time);
void onRunningGameChanged(QString filename, QString game_code, QString game_title);
void onRunningGameChanged(const QString& filename, const QString& game_code, const QString& game_title);
void onStartDiscActionTriggered();
void onChangeDiscFromFileActionTriggered();

View File

@ -167,11 +167,11 @@ QtDisplayWindow* QtHostInterface::createDisplayWindow()
return m_display_window;
}
void QtHostInterface::bootSystemFromFile(QString filename)
void QtHostInterface::bootSystemFromFile(const QString& filename)
{
if (!isOnWorkerThread())
{
QMetaObject::invokeMethod(this, "bootSystemFromFile", Qt::QueuedConnection, Q_ARG(QString, filename));
QMetaObject::invokeMethod(this, "bootSystemFromFile", Qt::QueuedConnection, Q_ARG(const QString&, filename));
return;
}
@ -527,7 +527,7 @@ void QtHostInterface::pauseSystem(bool paused)
emit emulationPaused(paused);
}
void QtHostInterface::changeDisc(QString new_disc_filename) {}
void QtHostInterface::changeDisc(const QString& new_disc_filename) {}
void QtHostInterface::populateSaveStateMenus(const char* game_code, QMenu* load_menu, QMenu* save_menu)
{
@ -579,11 +579,11 @@ void QtHostInterface::populateSaveStateMenus(const char* game_code, QMenu* load_
}
}
void QtHostInterface::loadState(QString filename)
void QtHostInterface::loadState(const QString& filename)
{
if (!isOnWorkerThread())
{
QMetaObject::invokeMethod(this, "loadState", Qt::QueuedConnection, Q_ARG(QString, filename));
QMetaObject::invokeMethod(this, "loadState", Qt::QueuedConnection, Q_ARG(const QString&, filename));
return;
}

View File

@ -61,8 +61,8 @@ public:
void populateSaveStateMenus(const char* game_code, QMenu* load_menu, QMenu* save_menu);
Q_SIGNALS:
void errorReported(QString message);
void messageReported(QString message);
void errorReported(const QString& message);
void messageReported(const QString& message);
void emulationStarted();
void emulationStopped();
void emulationPaused(bool paused);
@ -72,17 +72,17 @@ Q_SIGNALS:
void toggleFullscreenRequested();
void systemPerformanceCountersUpdated(float speed, float fps, float vps, float avg_frame_time,
float worst_frame_time);
void runningGameChanged(QString filename, QString game_code, QString game_title);
void runningGameChanged(const QString& filename, const QString& game_code, const QString& game_title);
public Q_SLOTS:
void applySettings();
void bootSystemFromFile(QString filename);
void bootSystemFromFile(const QString& filename);
void bootSystemFromBIOS();
void destroySystem(bool save_resume_state = false, bool block_until_done = false);
void resetSystem();
void pauseSystem(bool paused);
void changeDisc(QString new_disc_filename);
void loadState(QString filename);
void changeDisc(const QString& new_disc_filename);
void loadState(const QString& filename);
void loadState(bool global, qint32 slot);
void saveState(bool global, qint32 slot, bool block_until_done = false);