* @brief Debounced watcher handler: ignores self-saves (hash unchanged), flags deletion, * and prompts to reload when another program modified the project file. */
| 7772 | * and prompts to reload when another program modified the project file. |
| 7773 | */ |
| 7774 | void DataModel::ProjectModel::resolveDiskFileChange() |
| 7775 | { |
| 7776 | m_diskCheckPending = false; |
| 7777 | if (m_diskPromptActive || m_filePath.isEmpty()) |
| 7778 | return; |
| 7779 | |
| 7780 | if (!QFile::exists(m_filePath)) { |
| 7781 | m_diskFileHash.clear(); |
| 7782 | m_modified = true; |
| 7783 | Q_EMIT modifiedChanged(); |
| 7784 | Q_EMIT projectFileChangedOnDisk(); |
| 7785 | DataModel::NotificationCenter::instance().postWarning( |
| 7786 | QStringLiteral("ProjectModel"), |
| 7787 | tr("Project file removed from disk"), |
| 7788 | tr("%1 was deleted or renamed by another program. Save the project to recreate it.") |
| 7789 | .arg(jsonFileName())); |
| 7790 | return; |
| 7791 | } |
| 7792 | |
| 7793 | if (!m_fileWatcher->files().contains(m_filePath)) |
| 7794 | m_fileWatcher->addPath(m_filePath); |
| 7795 | |
| 7796 | const auto hash = hashProjectFile(m_filePath); |
| 7797 | if (hash.isEmpty() || hash == m_diskFileHash) |
| 7798 | return; |
| 7799 | |
| 7800 | m_diskFileHash = hash; |
| 7801 | Q_EMIT projectFileChangedOnDisk(); |
| 7802 | |
| 7803 | if (m_suppressMessageBoxes) { |
| 7804 | qWarning() << "[ProjectModel] Project file changed on disk; keeping in-memory state"; |
| 7805 | m_modified = true; |
| 7806 | Q_EMIT modifiedChanged(); |
| 7807 | DataModel::NotificationCenter::instance().postWarning( |
| 7808 | QStringLiteral("ProjectModel"), |
| 7809 | tr("Project file changed on disk"), |
| 7810 | tr("%1 was modified by another program. The in-memory project was kept; reopen the " |
| 7811 | "file to load the external changes.") |
| 7812 | .arg(jsonFileName())); |
| 7813 | return; |
| 7814 | } |
| 7815 | |
| 7816 | promptDiskFileReload(); |
| 7817 | } |
| 7818 | |
| 7819 | /** |
| 7820 | * @brief Asks whether to reload the externally-modified project file; declining keeps the |
nothing calls this directly
no test coverage detected