Fix crash when pressing key bind reset button in settings
authorWuzzy <Wuzzy2@mail.ru>
Mon, 29 Apr 2019 23:12:40 +0200
changeset 14873 56293aa24e81
parent 14872 058e204908a6
child 14874 b96ba3c1ab67
Fix crash when pressing key bind reset button in settings
QTfrontend/ui/page/pageoptions.cpp
--- a/QTfrontend/ui/page/pageoptions.cpp	Mon Apr 29 22:09:04 2019 +0200
+++ b/QTfrontend/ui/page/pageoptions.cpp	Mon Apr 29 23:12:40 2019 +0200
@@ -1240,9 +1240,12 @@
 // Returns: The bind model index of the default.
 int PageOptions::resetBindToDefault(int bindID)
 {
+    if (QString(cbinds[bindID].action) == QString("!MULTI"))
+        return -1;
     QStandardItemModel * binds = DataManager::instance().bindsModel();
     QModelIndexList mdl = binds->match(binds->index(0, 0), Qt::UserRole + 1, cbinds[bindID].strbind, 1, Qt::MatchExactly);
-    if(mdl.size() == 1) binder->setBindIndex(bindID, mdl[0].row());
+    if(mdl.size() == 1)
+        binder->setBindIndex(bindID, mdl[0].row());
     return mdl[0].row();
 }
 
@@ -1251,7 +1254,8 @@
 {
     for (int i = 0; i < BINDS_NUMBER; i++)
     {
-        resetBindToDefault(i);
-        bindUpdated(i);
+        int ret = resetBindToDefault(i);
+        if(ret != -1)
+            bindUpdated(i);
     }
 }