Skip to content

Commit

Permalink
fix #76751: crash when opening plugin manager
Browse files Browse the repository at this point in the history
The reason was not updated plugins list as local Preferences variable. It was updated only after the for loop, but setData() calls pluginLoadToggled() which seeks for the actual plugin in the list.
  • Loading branch information
anatoly-os committed Jun 25, 2018
1 parent 6c0bd3a commit 7357da2
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions mscore/pluginManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ void PluginManager::init()
void PluginManager::loadList(bool forceRefresh)
{
QStringList saveLoaded; // If forcing a refresh, the load flags are lost. Keep a copy and reapply.
int n = preferences.pluginList.size();
if (forceRefresh && n > 0) {
for (int i = 0; i < n; i++) {
const int sizeBeforeReloading = preferences.pluginList.size();
if (forceRefresh && sizeBeforeReloading > 0) {
for (int i = 0; i < sizeBeforeReloading; i++) {
PluginDescription& d = preferences.pluginList[i];
if (d.load) {
saveLoaded.append(d.path);
Expand All @@ -73,9 +73,13 @@ void PluginManager::loadList(bool forceRefresh)
}
}
preferences.updatePluginList(forceRefresh);
n = preferences.pluginList.size();
//we need to assign updated preferences before for() loop
//because setData() in the loop silently calls pluginLoadToggled() which uses local prefs variable
prefs = preferences;

const int sizeAfterUpdate = preferences.pluginList.size();
pluginList->clear();
for (int i = 0; i < n; ++i) {
for (int i = 0; i < sizeAfterUpdate; ++i) {
PluginDescription& d = preferences.pluginList[i];
Shortcut* s = &d.shortcut;
localShortcuts[s->key()] = new Shortcut(*s);
Expand All @@ -85,8 +89,8 @@ void PluginManager::loadList(bool forceRefresh)
item->setCheckState(d.load ? Qt::Checked : Qt::Unchecked);
item->setData(Qt::UserRole, i);
}
prefs = preferences;
if (n) {

if (sizeAfterUpdate) {
pluginList->setCurrentRow(0);
pluginListItemChanged(pluginList->item(0), 0);
}
Expand Down

0 comments on commit 7357da2

Please sign in to comment.