Skip to content

Commit 1816b93

Browse files
committed
Qt: prune dead getters, signals, forward decls, and locals
Pure dead-code removal in three files. No behaviour change. * ui_qt.h: drop 8 redundant forward declarations. GridView, ShaderParamsDialog, CoreOptionsDialog, CoreInfoDialog, PlaylistEntryDialog and ViewOptionsDialog all have full definitions in ui_qt_widgets.h, which ui_qt.h includes at line 46 - the forward decls below the include were noise. MainWindow and ThumbnailWidget were forward-declared at the top of ui_qt.h but never referenced before their own definitions later in the same file. Only the ThumbnailLabel forward decl is load-bearing - ThumbnailWidget references ThumbnailLabel* as a member before ThumbnailLabel is defined. * MainWindow: drop 5 dead signals and 4 dead connect() calls. - gotReloadCoreOptions, gotThumbnailDownload, updateThumbnails and extractArchiveDeferred each had a connect() in the constructor but were never emitted anywhere - the signal connections were inert. The slots they pointed to (onDownloadThumbnail, onGotReloadCoreOptions, onExtractArchive, updateVisibleItems) all stay - they have other callers, either via direct calls or via QMetaObject::invokeMethod. - gridItemChanged was declared but neither emitted nor connected. * MainWindow: drop 3 dead public getters. contentTableView(), contentGridView() and searchWidget() were declared and defined but had zero callers across ui/, libretro- common/, frontend/, menu/, and retroarch.c. * MainWindow::MainWindow: drop dead 'QDir playlistDir' and the path_dir_playlist local that only existed to construct it. Both unused since the constructor split. -Wunused-variable did not flag the QDir because of its non-trivial constructor. * MainWindow::changeThumbnail: replace QDir.exists() / QDir.mkpath pair with path_is_directory() / path_mkdir() from libretro- common, dropping one more QDir local. mkpath(".") and path_mkdir() both create parent directories recursively. * MainWindow::setCoreActions: drop dead 'QFileInfo info' block ('info' was assigned via setFile() but never read) and a dead 'coreName = "<n/a>"' assignment in a then-branch that did nothing else with coreName. * qt_companion_select_initial_playlist: drop redundant 'listWidget->count() &&' guard from two for-loop conditions ('i < count' is already false when count is 0). * ui_qt_widgets.cpp: drop pre-existing dead 'uint32_t flags = runloop_st->flags' local in CoreOptionsDialog (-Wunused-variable was suppressed in the build and so this slipped in years ago).
1 parent a9878b1 commit 1816b93

3 files changed

Lines changed: 25 additions & 66 deletions

File tree

ui/drivers/ui_qt.cpp

Lines changed: 25 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1945,12 +1945,9 @@ void MainWindow::setupSignalConnections()
19451945
this, SLOT(onThumbnailPackDownloadCanceled()));
19461946

19471947
connect(this, SIGNAL(itemChanged()), this, SLOT(onItemChanged()));
1948-
connect(this, SIGNAL(gotThumbnailDownload(QString,QString)),
1949-
this, SLOT(onDownloadThumbnail(QString,QString)));
19501948

19511949
m_thumbnailTimer->setSingleShot(true);
19521950
connect(m_thumbnailTimer, SIGNAL(timeout()), this, SLOT(updateVisibleItems()));
1953-
connect(this, SIGNAL(updateThumbnails()), this, SLOT(updateVisibleItems()));
19541951

19551952
/* TODO: Handle scroll and resize differently. */
19561953
connect(m_gridView, SIGNAL(visibleItemsChangedMaybe()),
@@ -1991,18 +1988,12 @@ void MainWindow::setupSignalConnections()
19911988
SLOT(onGotReloadShaderParams()), Qt::AutoConnection);
19921989
#endif
19931990
#endif
1994-
connect(this, SIGNAL(gotReloadCoreOptions()), this,
1995-
SLOT(onGotReloadCoreOptions()), Qt::AutoConnection);
19961991

19971992
/* These are always queued */
19981993
connect(this, SIGNAL(showErrorMessageDeferred(QString)), this,
19991994
SLOT(onShowErrorMessage(QString)), Qt::QueuedConnection);
20001995
connect(this, SIGNAL(showInfoMessageDeferred(QString)), this,
20011996
SLOT(onShowInfoMessage(QString)), Qt::QueuedConnection);
2002-
connect(this, SIGNAL(extractArchiveDeferred(QString,QString,
2003-
QString,retro_task_callback_t)), this,
2004-
SLOT(onExtractArchive(QString,QString,QString,retro_task_callback_t)),
2005-
Qt::QueuedConnection);
20061997
}
20071998

20081999
MainWindow::~MainWindow()
@@ -2585,12 +2576,11 @@ QString MainWindow::changeThumbnail(const QImage &image, QString type)
25852576
QByteArray thumbArray = QDir::toNativeSeparators(thumbPath).toUtf8();
25862577
const char *thumbData = thumbArray.constData();
25872578
int quality = -1;
2588-
QDir dir(dirString);
25892579
QImage scaledImage(image);
25902580

2591-
if (!dir.exists())
2581+
if (!path_is_directory(dirData))
25922582
{
2593-
if (!dir.mkpath("."))
2583+
if (!path_mkdir(dirData))
25942584
{
25952585
RARCH_ERR("[Qt] Could not create directory: \"%s\".\n", dirData);
25962586
return QString();
@@ -3115,41 +3105,34 @@ void MainWindow::setCoreActions()
31153105
{
31163106
QString coreName = hash["core_name"];
31173107

3118-
if (coreName.isEmpty())
3119-
coreName = QString("<n/a>");
3120-
else
3108+
if (!coreName.isEmpty() && coreName != QLatin1String("DETECT"))
31213109
{
3122-
const char *detect_str = "DETECT";
3123-
3124-
if (coreName != detect_str)
3110+
if (m_launchWithComboBox->findText(coreName) == -1)
31253111
{
3126-
if (m_launchWithComboBox->findText(coreName) == -1)
3112+
int i;
3113+
bool found_existing = false;
3114+
3115+
for (i = 0; i < m_launchWithComboBox->count(); i++)
31273116
{
3128-
int i;
3129-
bool found_existing = false;
3117+
QVariantMap map = m_launchWithComboBox->itemData(
3118+
i, Qt::UserRole).toMap();
31303119

3131-
for (i = 0; i < m_launchWithComboBox->count(); i++)
3120+
if ( map.value("core_path").toString() == hash["core_path"]
3121+
|| map.value("core_name").toString() == coreName)
31323122
{
3133-
QVariantMap map = m_launchWithComboBox->itemData(
3134-
i, Qt::UserRole).toMap();
3135-
3136-
if ( map.value("core_path").toString() == hash["core_path"]
3137-
|| map.value("core_name").toString() == coreName)
3138-
{
3139-
found_existing = true;
3140-
break;
3141-
}
3123+
found_existing = true;
3124+
break;
31423125
}
3126+
}
31433127

3144-
if (!found_existing)
3145-
{
3146-
QVariantMap comboBoxMap;
3147-
comboBoxMap["core_name"] = coreName;
3148-
comboBoxMap["core_path"] = hash["core_path"];
3149-
comboBoxMap["core_selection"] = CORE_SELECTION_PLAYLIST_SAVED;
3150-
m_launchWithComboBox->addItem(coreName,
3151-
QVariant::fromValue(comboBoxMap));
3152-
}
3128+
if (!found_existing)
3129+
{
3130+
QVariantMap comboBoxMap;
3131+
comboBoxMap["core_name"] = coreName;
3132+
comboBoxMap["core_path"] = hash["core_path"];
3133+
comboBoxMap["core_selection"] = CORE_SELECTION_PLAYLIST_SAVED;
3134+
m_launchWithComboBox->addItem(coreName,
3135+
QVariant::fromValue(comboBoxMap));
31533136
}
31543137
}
31553138
}
@@ -3193,13 +3176,10 @@ void MainWindow::setCoreActions()
31933176

31943177
if (allPlaylists)
31953178
{
3196-
QFileInfo info;
31973179
QListWidgetItem *listItem = m_listWidget->item(row);
31983180
QString listItemString = listItem->data(
31993181
Qt::UserRole).toString();
32003182

3201-
info.setFile(listItemString);
3202-
32033183
if (listItemString == ALL_PLAYLISTS_TOKEN)
32043184
continue;
32053185
}
@@ -3467,7 +3447,6 @@ void MainWindow::onShowHiddenDockWidgetAction()
34673447
}
34683448
}
34693449

3470-
QWidget* MainWindow::searchWidget() { return m_searchWidget; }
34713450
QLineEdit* MainWindow::searchLineEdit() { return m_searchLineEdit; }
34723451
void MainWindow::onSearchEnterPressed()
34733452
{
@@ -3723,12 +3702,10 @@ void MainWindow::onCurrentListItemChanged(
37233702
setCoreActions();
37243703
}
37253704

3726-
TableView* MainWindow::contentTableView() { return m_tableView; }
37273705
QTableView* MainWindow::fileTableView() { return m_fileTableView; }
37283706
QStackedWidget* MainWindow::centralWidget() { return m_centralWidget; }
37293707
FileDropWidget* MainWindow::playlistViews() { return m_playlistViews; }
37303708
QWidget* MainWindow::playlistViewsAndFooter() {return m_playlistViewsAndFooter;}
3731-
GridView* MainWindow::contentGridView() { return m_gridView; }
37323709

37333710
void MainWindow::onBrowserDownloadsClicked()
37343711
{
@@ -5041,7 +5018,7 @@ static void qt_companion_select_initial_playlist(QListWidget *listWidget,
50415018
int i;
50425019
bool found = false;
50435020

5044-
for (i = 0; listWidget->count() && i < listWidget->count(); i++)
5021+
for (i = 0; i < listWidget->count(); i++)
50455022
{
50465023
QListWidgetItem *item = listWidget->item(i);
50475024
QString path;
@@ -5064,7 +5041,7 @@ static void qt_companion_select_initial_playlist(QListWidget *listWidget,
50645041
return;
50655042

50665043
/* Couldn't find the user's initial playlist, just find anything. */
5067-
for (i = 0; listWidget->count() && i < listWidget->count(); i++)
5044+
for (i = 0; i < listWidget->count(); i++)
50685045
{
50695046
if (!listWidget->isRowHidden(i))
50705047
{

ui/drivers/ui_qt.h

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -96,15 +96,7 @@ class QSlider;
9696
class QDragEnterEvent;
9797
class QDropEvent;
9898
class QProgressDialog;
99-
class MainWindow;
100-
class ThumbnailWidget;
10199
class ThumbnailLabel;
102-
class GridView;
103-
class ShaderParamsDialog;
104-
class CoreOptionsDialog;
105-
class CoreInfoDialog;
106-
class PlaylistEntryDialog;
107-
class ViewOptionsDialog;
108100

109101
enum SpecialPlaylist
110102
{
@@ -471,12 +463,9 @@ class MainWindow : public QMainWindow
471463
PlaylistModel* playlistModel();
472464
ListWidget* playlistListWidget();
473465
QStackedWidget* centralWidget();
474-
TableView* contentTableView();
475466
QTableView* fileTableView();
476467
FileDropWidget* playlistViews();
477-
GridView* contentGridView();
478468
QWidget* playlistViewsAndFooter();
479-
QWidget* searchWidget();
480469
QLineEdit* searchLineEdit();
481470
QComboBox* launchWithComboBox();
482471
QToolButton* startCorePushButton();
@@ -524,14 +513,9 @@ class MainWindow : public QMainWindow
524513
void gotStatusMessage(QString msg, unsigned priority, unsigned duration, bool flush);
525514
void gotReloadPlaylists();
526515
void gotReloadShaderParams();
527-
void gotReloadCoreOptions();
528516
void showErrorMessageDeferred(QString msg);
529517
void showInfoMessageDeferred(QString msg);
530-
void extractArchiveDeferred(QString path, QString extractionDir, QString tempExtension, retro_task_callback_t cb);
531518
void itemChanged();
532-
void updateThumbnails();
533-
void gridItemChanged(QString title);
534-
void gotThumbnailDownload(QString system, QString title);
535519
void scrollToDownloads(QString path);
536520
void scrollToDownloadsAgain(QString path);
537521

ui/drivers/ui_qt_widgets.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2922,8 +2922,6 @@ void CoreOptionsDialog::buildLayout()
29222922

29232923
if (!contentLabel.isEmpty())
29242924
{
2925-
uint32_t flags = runloop_st->flags;
2926-
29272925
if (!label.isEmpty())
29282926
{
29292927
QHBoxLayout *gameOptionsLayout = new QHBoxLayout();

0 commit comments

Comments
 (0)