]> Devoid-pointer.net GitWeb - FFBChecker.git/commitdiff
Use proper MVC in removeAndEraseEffect() handler.
authorMichal Malý <madcatxster@devoid-pointer.net>
Wed, 8 Jul 2015 15:48:06 +0000 (17:48 +0200)
committerMichal Malý <madcatxster@devoid-pointer.net>
Wed, 8 Jul 2015 15:48:06 +0000 (17:48 +0200)
mainwindow.cpp

index 07257f0d01a0010141699e12609fd7bb7f47d077..fa308a98baf448bf6818e0b5be77e52f816ef4da 100644 (file)
@@ -177,9 +177,19 @@ void MainWindow::onRefreshDevicesClicked()
 
 void MainWindow::onRemoveEffectClicked()
 {
+  int effectIdx;
+  bool ok;
+
   if (m_activeDevice == nullptr)
     return;
-  if (!m_activeDevice->removeAndEraseEffect(ui->cbox_effectSlots->currentIndex()))
+
+  effectIdx = ui->cbox_effectSlots->currentData(Qt::UserRole).toInt(&ok);
+  if (!ok) {
+    showErrorMsgBox(ErrorMessages::BAD_EFFECT_SLOT);
+    return;
+  }
+
+  if (!m_activeDevice->removeAndEraseEffect(effectIdx))
     showErrorMsgBox(ErrorMessages::CANT_REMOVE_EFFECT);
   else
     setEffectStatusText(FFBEffect::FFBEffectStatus::NOT_LOADED);