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 | 224 | if (!_isReloading) { |
| 225 | 225 | _isReloading = true; |
| 226 | 226 | |
| 227 | − if (QFileInfo(_currentScript).lastModified() > _currentScriptModified) { | |
| 227 | + QDateTime fileStamp = QFileInfo(_currentScript).lastModified(); | |
| 228 | + if (fileStamp > _currentScriptModified) { | |
| 228 | 229 | bool doReload = false; |
| 229 | 230 | auto window = static_cast<ScriptEditorWindow*>(this->parent()->parent()->parent()); |
| 230 | 231 | window->inModalDialog = true; |
| 231 | 232 | if (window->autoReloadScripts() |
| 232 | 233 | || OffscreenUi::question(this, tr("Reload Script"), |
| 233 | − tr("The following file has been modified outside of the Interface editor:") + "\n" + _currentScript + "\n" | |
| 234 | − + (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?")), | |
| 237 | − QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) { | |
| 234 | + tr("The following file has been modified outside of the Interface editor:") + "\n" + _currentScript + "\n" | |
| 235 | + + (isModified() | |
| 236 | + ? tr("Do you want to reload it and lose the changes you've made in the Interface editor?") | |
| 237 | + : tr("Do you want to reload it?")), | |
| 238 | + QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) { | |
| 238 | 239 | doReload = true; |
| 239 | 240 | } |
| 240 | 241 | window->inModalDialog = false; |
| @@ -245,8 +246,10 @@ void ScriptEditorWidget::onWindowActivated() { · 4 unmodified lines | ||
| 245 | 246 | setRunning(false); |
| 246 | 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 | 253 | _isReloading = false; |
| 251 | 254 | } |
| 252 | −} | |
| 255 | +} | |