Skip to content

Commit

Permalink
Merge pull request #2128 from ekigwana/fix_model_crash
Browse files Browse the repository at this point in the history
Ensure model is not empty before removing rows.
  • Loading branch information
uklotzde committed May 30, 2019
2 parents 2876bee + e324e5a commit 86ff072
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
8 changes: 5 additions & 3 deletions src/preferences/broadcastsettingsmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ void BroadcastSettingsModel::resetFromSettings(BroadcastSettingsPointer pSetting
return;
}

beginRemoveRows(QModelIndex(), 0, m_profiles.size()-1);
endRemoveRows();
m_profiles.clear();
if (!m_profiles.isEmpty()) {
beginRemoveRows(QModelIndex(), 0, m_profiles.size()-1);
endRemoveRows();
m_profiles.clear();
}

for(BroadcastProfilePtr profile : pSettings->profiles()) {
BroadcastProfilePtr copy = profile->valuesCopy();
Expand Down
8 changes: 5 additions & 3 deletions src/preferences/effectsettingsmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ void EffectSettingsModel::resetFromEffectManager(EffectsManager* pEffectsManager
return;
}

beginRemoveRows(QModelIndex(), 0, m_profiles.size()-1);
endRemoveRows();
m_profiles.clear();
if (!m_profiles.isEmpty()) {
beginRemoveRows(QModelIndex(), 0, m_profiles.size()-1);
endRemoveRows();
m_profiles.clear();
}

for (EffectManifestPointer pManifest : pEffectsManager->getAvailableEffectManifests()) {
const bool visibility = pEffectsManager->getEffectVisibility(pManifest);
Expand Down

0 comments on commit 86ff072

Please sign in to comment.