logic: crash fixes

<description>
This commit is contained in:
Eberhard Graether
2015-08-07 00:17:41 +02:00
parent 30b5abd672
commit 30c941fcf8
3 changed files with 27 additions and 15 deletions
+24 -14
View File
@@ -64,20 +64,7 @@ void Application::loadProject(const std::string& projectSettingsFilePath)
m_project->loadProjectSettings(projectSettingsFilePath);
m_project->parseCode();
std::vector<std::string> recentProjects = ApplicationSettings::getInstance()->getRecentProjects();
if (recentProjects.size())
{
recentProjects.erase(std::find(recentProjects.begin(), recentProjects.end(), projectSettingsFilePath));
}
recentProjects.insert(recentProjects.begin(), projectSettingsFilePath);
if (recentProjects.size() > 7)
{
recentProjects.pop_back();
}
ApplicationSettings::getInstance()->setRecentProjects(recentProjects);
ApplicationSettings::getInstance()->save("data/ApplicationSettings.xml");
updateRecentProjects(projectSettingsFilePath);
}
void Application::loadSource(const std::string& sourceDirectoryPath)
@@ -176,3 +163,26 @@ void Application::handleMessage(MessageSaveProject* message)
{
saveProject(message->projectSettingsFilePath);
}
void Application::updateRecentProjects(const std::string& projectSettingsFilePath)
{
ApplicationSettings* appSettings = ApplicationSettings::getInstance().get();
std::vector<std::string> recentProjects = appSettings->getRecentProjects();
if (recentProjects.size())
{
std::vector<std::string>::iterator it = std::find(recentProjects.begin(), recentProjects.end(), projectSettingsFilePath);
if (it != recentProjects.end())
{
recentProjects.erase(it);
}
}
recentProjects.insert(recentProjects.begin(), projectSettingsFilePath);
if (recentProjects.size() > 7)
{
recentProjects.pop_back();
}
appSettings->setRecentProjects(recentProjects);
appSettings->save("data/ApplicationSettings.xml");
}
+2
View File
@@ -43,6 +43,8 @@ private:
virtual void handleMessage(MessageRefresh* message);
virtual void handleMessage(MessageSaveProject* message);
void updateRecentProjects(const std::string& projectSettingsFilePath);
std::shared_ptr<Project> m_project;
std::shared_ptr<StorageCache> m_storageCache;
+1 -1
View File
@@ -114,7 +114,7 @@ std::set<FilePath> Storage::getDependingFilePathsAndRemoveFileNodes(const std::s
{
Node* fileNode = findFileNode(filePath);
if (!fileNode->getComponent<TokenComponentFilePath>() ||
if (!fileNode || !fileNode->getComponent<TokenComponentFilePath>() ||
fileNode->getComponent<TokenComponentFilePath>()->getFilePath() != filePath)
{
LOG_ERROR("Node is not resolving to the same file.");