From 8a1c42450d955bb685ce8af134ad1569fb36b904 Mon Sep 17 00:00:00 2001 From: eidheim Date: Sun, 20 Mar 2016 09:50:56 +0100 Subject: [PATCH] Minor cleanup of project code --- src/notebook.cc | 19 +++---------------- src/project.cc | 22 ++++++++++++++++++++++ src/project.h | 1 + src/project_build.cc | 6 +++++- 4 files changed, 31 insertions(+), 17 deletions(-) diff --git a/src/notebook.cc b/src/notebook.cc index 0497b21..ab4541d 100644 --- a/src/notebook.cc +++ b/src/notebook.cc @@ -4,7 +4,7 @@ #include "logging.h" #include #include -#include "project_build.h" +#include "project.h" #include "filesystem.h" #if GTKSOURCEVIEWMM_MAJOR_VERSION > 2 & GTKSOURCEVIEWMM_MINOR_VERSION > 17 @@ -243,21 +243,8 @@ bool Notebook::save(int page) { view->get_buffer()->set_modified(false); - //If CMakeLists.txt have been modified: - boost::filesystem::path project_path; - if(view->file_path.filename()=="CMakeLists.txt") { - auto build=Project::get_build(view->file_path); - build->update_default_build(true); - if(boost::filesystem::exists(build->get_debug_build_path())) - build->update_debug_build(true); - - for(auto source_view: source_views) { - if(auto source_clang_view=dynamic_cast(source_view)) { - if(filesystem::file_in_path(source_clang_view->file_path, build->project_path)) - source_clang_view->full_reparse_needed=true; - } - } - } + Project::on_save(); + JDEBUG("end true"); return true; } diff --git a/src/project.cc b/src/project.cc index cf2c5d3..76a74ab 100644 --- a/src/project.cc +++ b/src/project.cc @@ -35,6 +35,28 @@ void Project::save_files(const boost::filesystem::path &path) { } } +void Project::on_save() { + if(Notebook::get().get_current_page()==-1) + return; + auto view=Notebook::get().get_current_view(); + if(view->file_path.filename()=="CMakeLists.txt") { + auto build=get_build(view->file_path); + if(dynamic_cast(build.get())) { + build->update_default_build(true); + if(boost::filesystem::exists(build->get_debug_build_path())) + build->update_debug_build(true); + + for(int c=0;c(source_view)) { + if(filesystem::file_in_path(source_clang_view->file_path, build->project_path)) + source_clang_view->full_reparse_needed=true; + } + } + } + } +} + void Project::debug_update_status(const std::string &debug_status) { if(debug_status.empty()) debug_status_label().set_text(""); diff --git a/src/project.h b/src/project.h index e81e346..285b341 100644 --- a/src/project.h +++ b/src/project.h @@ -14,6 +14,7 @@ namespace Project { Gtk::Label &debug_status_label(); void save_files(const boost::filesystem::path &path); + void on_save(); extern boost::filesystem::path debug_last_stop_file_path; extern std::unordered_map run_arguments; diff --git a/src/project_build.cc b/src/project_build.cc index 534742b..430d0fb 100644 --- a/src/project_build.cc +++ b/src/project_build.cc @@ -2,7 +2,11 @@ #include "config.h" std::unique_ptr Project::get_build(const boost::filesystem::path &path) { - return std::unique_ptr(new CMake(path)); + auto cmake=new CMake(path); + if(!cmake->project_path.empty()) + return std::unique_ptr(cmake); + else + return std::unique_ptr(new Project::Build()); } boost::filesystem::path Project::Build::get_default_build_path() {