Showing the changes to interface/src/ui/ScriptEditorWidget.cpp (1 of 1 file). Show all
Unified · Split
| @@ -224,17 +224,18 @@ void ScriptEditorWidget::onWindowActivated() { · 223 unmodified lines | |||
| 224 | if (!_isReloading) { | 224 | if (!_isReloading) { |
| 225 | _isReloading = true; | 225 | _isReloading = true; |
| 226 | 226 | ||
| 227 | if (QFileInfo(_currentScript).lastModified() > _currentScriptModified) { | 227 | QDateTime fileStamp = QFileInfo(_currentScript).lastModified(); |
| 228 | if (fileStamp > _currentScriptModified) { | ||
| 228 | bool doReload = false; | 229 | bool doReload = false; |
| 229 | auto window = static_cast<ScriptEditorWindow*>(this->parent()->parent()->parent()); | 230 | auto window = static_cast<ScriptEditorWindow*>(this->parent()->parent()->parent()); |
| 230 | window->inModalDialog = true; | 231 | window->inModalDialog = true; |
| 231 | if (window->autoReloadScripts() | 232 | if (window->autoReloadScripts() |
| 232 | || OffscreenUi::question(this, tr("Reload Script"), | 233 | || OffscreenUi::question(this, tr("Reload Script"), |
| 233 | tr("The following file has been modified outside of the Interface editor:") + "\n" + _currentScript + "\n" | 234 | tr("The following file has been modified outside of the Interface editor:") + "\n" + _currentScript + "\n" |
| 234 | + (isModified() | 235 | + (isModified() |
| 235 | ? tr("Do you want to reload it and lose the changes you've made in the Interface editor?") | 236 | ? tr("Do you want to reload it and lose the changes you've made in the Interface editor?") |
| 236 | : tr("Do you want to reload it?")), | 237 | : tr("Do you want to reload it?")), |
| 237 | QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) { | 238 | QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) { |
| 238 | doReload = true; | 239 | doReload = true; |
| 239 | } | 240 | } |
| 240 | window->inModalDialog = false; | 241 | window->inModalDialog = false; |
| @@ -245,8 +246,10 @@ void ScriptEditorWidget::onWindowActivated() { · 4 unmodified lines | |||
| 245 | setRunning(false); | 246 | setRunning(false); |
| 246 | // Script is restarted once current script instance finishes. | 247 | // Script is restarted once current script instance finishes. |
| 247 | } | 248 | } |
| 249 | } else { | ||
| 250 | _currentScriptModified = fileStamp; // Asked and answered. Don't ask again until the external file is changed again. | ||
| 248 | } | 251 | } |
| 249 | } | 252 | } |
| 250 | _isReloading = false; | 253 | _isReloading = false; |
| 251 | } | 254 | } |
| 252 | } | 255 | } |