| 241 | } |
| 242 | |
| 243 | void ScriptingWindow::deleteCurrentScript() |
| 244 | { |
| 245 | ScriptContainer* thisScript; |
| 246 | |
| 247 | int sel = ui->listLoadedScripts->currentRow(); |
| 248 | if (sel < 0) return; |
| 249 | |
| 250 | QMessageBox msgBox; |
| 251 | msgBox.setText("Really remove script?"); |
| 252 | msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); |
| 253 | msgBox.setDefaultButton(QMessageBox::No); |
| 254 | int ret = msgBox.exec(); |
| 255 | switch (ret) |
| 256 | { |
| 257 | case QMessageBox::Yes: |
| 258 | ui->listLoadedScripts->takeItem(sel); |
| 259 | thisScript = scripts.at(sel); |
| 260 | scripts.removeAt(sel); |
| 261 | delete thisScript; //causes a seg fault. Seems to be due to currently running javascript code. No idea how to stop code from running |
| 262 | thisScript = nullptr; |
| 263 | currentScript = nullptr; |
| 264 | |
| 265 | if (ui->listLoadedScripts->count() > 0) |
| 266 | { |
| 267 | ui->listLoadedScripts->setCurrentRow(0); |
| 268 | changeCurrentScript(); |
| 269 | } |
| 270 | else |
| 271 | { |
| 272 | editor->setPlainText(""); |
| 273 | editor->setEnabled(false); |
| 274 | } |
| 275 | break; |
| 276 | case QMessageBox::No: |
| 277 | break; |
| 278 | default: |
| 279 | // should never be reached |
| 280 | break; |
| 281 | } |
| 282 | } |
| 283 | |
| 284 | void ScriptingWindow::refreshSourceWindow() |
| 285 | { |