| @@ -253,11 +253,8 @@ void MainWindow::moveProject (File newProjectFileToOpen, OpenInIDE openInIDE) | |||||
| closeCurrentProject (OpenDocumentManager::SaveIfNeeded::no); | closeCurrentProject (OpenDocumentManager::SaveIfNeeded::no); | ||||
| openFile (newProjectFileToOpen); | openFile (newProjectFileToOpen); | ||||
| if (currentProject != nullptr) | |||||
| ProjucerApplication::getApp().getCommandManager() | |||||
| .invokeDirectly (openInIDE == OpenInIDE::yes ? CommandIDs::saveAndOpenInIDE | |||||
| : CommandIDs::saveProject, | |||||
| false); | |||||
| if (currentProject != nullptr && openInIDE == OpenInIDE::yes) | |||||
| ProjucerApplication::getApp().getCommandManager().invokeDirectly (CommandIDs::openInIDE, false); | |||||
| } | } | ||||
| void MainWindow::setProject (std::unique_ptr<Project> newProject) | void MainWindow::setProject (std::unique_ptr<Project> newProject) | ||||
| @@ -970,7 +970,8 @@ void Project::saveAndMoveTemporaryProject (bool openInIDE) | |||||
| auto newDirectory = newParentDirectory.getChildFile (tempDirectory.getFileName()); | auto newDirectory = newParentDirectory.getChildFile (tempDirectory.getFileName()); | ||||
| auto oldJucerFileName = getFile().getFileName(); | auto oldJucerFileName = getFile().getFileName(); | ||||
| writeProjectFile(); | |||||
| ProjectSaver saver (*this); | |||||
| saver.save(); | |||||
| tempDirectory.copyDirectoryTo (newDirectory); | tempDirectory.copyDirectoryTo (newDirectory); | ||||
| tempDirectory.deleteRecursively(); | tempDirectory.deleteRecursively(); | ||||
| @@ -1091,20 +1092,6 @@ bool Project::updateCachedFileState() | |||||
| return true; | return true; | ||||
| } | } | ||||
| void Project::writeProjectFile() | |||||
| { | |||||
| updateCachedFileState(); | |||||
| auto newSerialisedXml = serialiseProjectXml (getProjectRoot().createXml()); | |||||
| jassert (newSerialisedXml.isNotEmpty()); | |||||
| if (newSerialisedXml != cachedFileState.second) | |||||
| { | |||||
| getFile().replaceWithText (newSerialisedXml); | |||||
| cachedFileState = { getFile().getLastModificationTime(), newSerialisedXml }; | |||||
| } | |||||
| } | |||||
| //============================================================================== | //============================================================================== | ||||
| File Project::resolveFilename (String filename) const | File Project::resolveFilename (String filename) const | ||||
| { | { | ||||
| @@ -475,7 +475,9 @@ public: | |||||
| //============================================================================== | //============================================================================== | ||||
| bool updateCachedFileState(); | bool updateCachedFileState(); | ||||
| void writeProjectFile(); | |||||
| String getCachedFileStateContent() const noexcept { return cachedFileState.second; } | |||||
| String serialiseProjectXml (std::unique_ptr<XmlElement>) const; | |||||
| //============================================================================== | //============================================================================== | ||||
| String getUniqueTargetFolderSuffixForExporter (const Identifier& exporterIdentifier, const String& baseTargetFolder); | String getUniqueTargetFolderSuffixForExporter (const Identifier& exporterIdentifier, const String& baseTargetFolder); | ||||
| @@ -566,7 +568,6 @@ private: | |||||
| std::pair<Time, String> cachedFileState; | std::pair<Time, String> cachedFileState; | ||||
| void saveAndMoveTemporaryProject (bool openInIDE); | void saveAndMoveTemporaryProject (bool openInIDE); | ||||
| String serialiseProjectXml (std::unique_ptr<XmlElement>) const; | |||||
| //============================================================================== | //============================================================================== | ||||
| friend class Item; | friend class Item; | ||||
| @@ -30,6 +30,8 @@ | |||||
| static constexpr const char* generatedGroupID = "__jucelibfiles"; | static constexpr const char* generatedGroupID = "__jucelibfiles"; | ||||
| static constexpr const char* generatedGroupUID = "__generatedcode__"; | static constexpr const char* generatedGroupUID = "__generatedcode__"; | ||||
| constexpr int jucerFormatVersion = 1; | |||||
| //============================================================================== | //============================================================================== | ||||
| ProjectSaver::ProjectSaver (Project& p) | ProjectSaver::ProjectSaver (Project& p) | ||||
| : project (p), | : project (p), | ||||
| @@ -294,7 +296,7 @@ Result ProjectSaver::saveProject (ProjectExporter* specifiedExporterToSave) | |||||
| writeProjects (modules, specifiedExporterToSave); | writeProjects (modules, specifiedExporterToSave); | ||||
| runPostExportScript(); | runPostExportScript(); | ||||
| project.writeProjectFile(); | |||||
| writeProjectFile(); | |||||
| if (generatedCodeFolder.exists()) | if (generatedCodeFolder.exists()) | ||||
| { | { | ||||
| @@ -332,6 +334,25 @@ void ProjectSaver::writePluginDefines (MemoryOutputStream& out) const | |||||
| << pluginDefines << newLine; | << pluginDefines << newLine; | ||||
| } | } | ||||
| void ProjectSaver::writeProjectFile() | |||||
| { | |||||
| auto root = project.getProjectRoot(); | |||||
| root.removeProperty ("jucerVersion", nullptr); | |||||
| root.setProperty (Ids::jucerFormatVersion, jucerFormatVersion, nullptr); | |||||
| project.updateCachedFileState(); | |||||
| auto newSerialisedXml = project.serialiseProjectXml (root.createXml()); | |||||
| jassert (newSerialisedXml.isNotEmpty()); | |||||
| if (newSerialisedXml != project.getCachedFileStateContent()) | |||||
| { | |||||
| project.getFile().replaceWithText (newSerialisedXml); | |||||
| project.updateCachedFileState(); | |||||
| } | |||||
| } | |||||
| void ProjectSaver::writeAppConfig (MemoryOutputStream& out, const OwnedArray<LibraryModule>& modules, const String& userContent) | void ProjectSaver::writeAppConfig (MemoryOutputStream& out, const OwnedArray<LibraryModule>& modules, const String& userContent) | ||||
| { | { | ||||
| if (! project.shouldUseAppConfig()) | if (! project.shouldUseAppConfig()) | ||||
| @@ -95,7 +95,7 @@ private: | |||||
| void writePluginDefines(); | void writePluginDefines(); | ||||
| void writeAppConfigFile (const OwnedArray<LibraryModule>& modules, const String& userContent); | void writeAppConfigFile (const OwnedArray<LibraryModule>& modules, const String& userContent); | ||||
| void writeMainProjectFile(); | |||||
| void writeProjectFile(); | |||||
| void writeAppConfig (MemoryOutputStream& outStream, const OwnedArray<LibraryModule>& modules, const String& userContent); | void writeAppConfig (MemoryOutputStream& outStream, const OwnedArray<LibraryModule>& modules, const String& userContent); | ||||
| void writeAppHeader (MemoryOutputStream& outStream, const OwnedArray<LibraryModule>& modules); | void writeAppHeader (MemoryOutputStream& outStream, const OwnedArray<LibraryModule>& modules); | ||||
| void writeAppHeader (const OwnedArray<LibraryModule>& modules); | void writeAppHeader (const OwnedArray<LibraryModule>& modules); | ||||
| @@ -370,6 +370,7 @@ namespace Ids | |||||
| DECLARE_ID (postExportShellCommandWin); | DECLARE_ID (postExportShellCommandWin); | ||||
| DECLARE_ID (liveBuildEnabled); | DECLARE_ID (liveBuildEnabled); | ||||
| DECLARE_ID (guiEditorEnabled); | DECLARE_ID (guiEditorEnabled); | ||||
| DECLARE_ID (jucerFormatVersion); | |||||
| const Identifier ID ("id"); | const Identifier ID ("id"); | ||||
| const Identifier ID_uppercase ("ID"); | const Identifier ID_uppercase ("ID"); | ||||