mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-26 15:45:42 +00:00
Qt: Fix crash on scanning empty directory
This commit is contained in:
parent
701780e2ef
commit
91fcb56148
|
@ -361,7 +361,8 @@ void ControllerMacroEditWidget::modFrequency(s32 delta)
|
|||
void ControllerMacroEditWidget::updateFrequency()
|
||||
{
|
||||
m_bwidget->getDialog()->setIntValue(m_bwidget->getConfigSection().c_str(),
|
||||
fmt::format("Macro{}Frequency", m_index).c_str(), static_cast<s32>(m_frequency));
|
||||
fmt::format("Macro{}Frequency", m_index + 1u).c_str(),
|
||||
static_cast<s32>(m_frequency));
|
||||
updateFrequencyText();
|
||||
}
|
||||
|
||||
|
|
|
@ -248,7 +248,7 @@ bool ControllerSettingsDialog::getBoolValue(const char* section, const char* key
|
|||
return Host::GetBaseBoolSettingValue(section, key, default_value);
|
||||
}
|
||||
|
||||
bool ControllerSettingsDialog::getIntValue(const char* section, const char* key, s32 default_value) const
|
||||
s32 ControllerSettingsDialog::getIntValue(const char* section, const char* key, s32 default_value) const
|
||||
{
|
||||
if (m_profile_interface)
|
||||
return m_profile_interface->GetIntValue(section, key, default_value);
|
||||
|
|
|
@ -50,7 +50,7 @@ public:
|
|||
|
||||
// Helper functions for updating setting values globally or in the profile.
|
||||
bool getBoolValue(const char* section, const char* key, bool default_value) const;
|
||||
bool getIntValue(const char* section, const char* key, s32 default_value) const;
|
||||
s32 getIntValue(const char* section, const char* key, s32 default_value) const;
|
||||
std::string getStringValue(const char* section, const char* key, const char* default_value) const;
|
||||
void setBoolValue(const char* section, const char* key, bool value);
|
||||
void setIntValue(const char* section, const char* key, s32 value);
|
||||
|
|
|
@ -420,6 +420,7 @@ void MainWindow::destroyDisplayWidget(bool show_game_list)
|
|||
{
|
||||
m_game_list_widget->setVisible(true);
|
||||
setCentralWidget(m_game_list_widget);
|
||||
m_game_list_widget->resizeTableViewColumnsToFit();
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -427,7 +428,10 @@ void MainWindow::destroyDisplayWidget(bool show_game_list)
|
|||
AssertMsg(m_ui.mainContainer->indexOf(m_display_widget) == 1, "Display widget in stack");
|
||||
m_ui.mainContainer->removeWidget(m_display_widget);
|
||||
if (show_game_list)
|
||||
{
|
||||
m_ui.mainContainer->setCurrentIndex(0);
|
||||
m_game_list_widget->resizeTableViewColumnsToFit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1187,6 +1191,7 @@ void MainWindow::onGameListRefreshProgress(const QString& status, int current, i
|
|||
|
||||
void MainWindow::onGameListRefreshComplete()
|
||||
{
|
||||
m_ui.statusBar->clearMessage();
|
||||
clearProgressBar();
|
||||
}
|
||||
|
||||
|
@ -1650,7 +1655,7 @@ void MainWindow::updateWindowState(bool force_visible)
|
|||
|
||||
void MainWindow::setProgressBar(int current, int total)
|
||||
{
|
||||
const int value = (current * 100) / total;
|
||||
const int value = (total != 0) ? ((current * 100) / total) : 0;
|
||||
if (m_status_progress_widget->value() != value)
|
||||
m_status_progress_widget->setValue(value);
|
||||
|
||||
|
|
|
@ -425,7 +425,6 @@ void GameList::ScanDirectory(const char* path, bool recursive, bool only_cache,
|
|||
{
|
||||
Log_InfoPrintf("Scanning %s%s", path, recursive ? " (recursively)" : "");
|
||||
|
||||
progress->PushState();
|
||||
progress->SetFormattedStatusText("Scanning directory '%s'%s...", path, recursive ? " (recursively)" : "");
|
||||
|
||||
FileSystem::FindResultsArray files;
|
||||
|
@ -433,11 +432,14 @@ void GameList::ScanDirectory(const char* path, bool recursive, bool only_cache,
|
|||
recursive ? (FILESYSTEM_FIND_FILES | FILESYSTEM_FIND_HIDDEN_FILES | FILESYSTEM_FIND_RECURSIVE) :
|
||||
(FILESYSTEM_FIND_FILES | FILESYSTEM_FIND_HIDDEN_FILES),
|
||||
&files);
|
||||
if (files.empty())
|
||||
return;
|
||||
|
||||
u32 files_scanned = 0;
|
||||
progress->PushState();
|
||||
progress->SetProgressRange(static_cast<u32>(files.size()));
|
||||
progress->SetProgressValue(0);
|
||||
|
||||
u32 files_scanned = 0;
|
||||
for (FILESYSTEM_FIND_DATA& ffd : files)
|
||||
{
|
||||
files_scanned++;
|
||||
|
|
|
@ -1144,7 +1144,7 @@ void InputManager::LoadMacroButtonConfig(SettingsInterface& si, const std::strin
|
|||
{
|
||||
if (button == cinfo->bindings[j].name)
|
||||
{
|
||||
binding = &cinfo->bindings[i];
|
||||
binding = &cinfo->bindings[j];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue