Browse Source

Now compiles with c++14 instead of c++11, and some src/git.* cleanup

merge-requests/365/head
eidheim 10 years ago
parent
commit
ccf7d3b9b2
  1. 2
      CMakeLists.txt
  2. 2
      README.md
  3. 3
      src/cmake.cc
  4. 2
      src/ctags.cc
  5. 8
      src/debug_lldb.cc
  6. 38
      src/directories.cc
  7. 31
      src/git.cc
  8. 19
      src/git.h
  9. 4
      src/project.cc
  10. 2
      src/project_build.cc
  11. 6
      src/source_clang.cc
  12. 4
      src/source_diff.cc
  13. 2
      src/source_spellcheck.cc
  14. 10
      src/terminal.cc
  15. 4
      src/tooltips.cc
  16. 8
      src/window.cc
  17. 4
      tests/git_test.cc

2
CMakeLists.txt

@ -3,7 +3,7 @@ cmake_minimum_required (VERSION 2.8.8)
set(project_name juci) set(project_name juci)
project (${project_name}) project (${project_name})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -pthread -Wall -Wextra -Wno-unused-parameter -Wno-reorder") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1y -pthread -Wall -Wextra -Wno-unused-parameter -Wno-reorder")
if(CMAKE_BUILD_TYPE STREQUAL "") if(CMAKE_BUILD_TYPE STREQUAL "")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3")
endif() endif()

2
README.md

@ -5,7 +5,7 @@
## About ## About
Current IDEs struggle with C++ support due to the complexity of Current IDEs struggle with C++ support due to the complexity of
the programming language. juCI++, however, is designed especially the programming language. juCI++, however, is designed especially
towards libclang with speed and ease of use in mind. towards libclang with speed, stability, and ease of use in mind.
## Features ## Features
* Platform independent * Platform independent

3
src/cmake.cc

@ -101,8 +101,7 @@ bool CMake::update_debug_build(const boost::filesystem::path &debug_build_path,
if(!force && boost::filesystem::exists(debug_build_path/"CMakeCache.txt")) if(!force && boost::filesystem::exists(debug_build_path/"CMakeCache.txt"))
return true; return true;
std::unique_ptr<Dialog::Message> message; auto message=std::make_unique<Dialog::Message>("Creating/updating debug build");
message=std::unique_ptr<Dialog::Message>(new Dialog::Message("Creating/updating debug build"));
auto exit_status=Terminal::get().process(Config::get().project.cmake_command+" "+ auto exit_status=Terminal::get().process(Config::get().project.cmake_command+" "+
filesystem::escape_argument(project_path)+" -DCMAKE_BUILD_TYPE=Debug", debug_build_path); filesystem::escape_argument(project_path)+" -DCMAKE_BUILD_TYPE=Debug", debug_build_path);
if(message) if(message)

2
src/ctags.cc

@ -37,7 +37,7 @@ std::pair<boost::filesystem::path, std::unique_ptr<std::stringstream> > Ctags::g
std::stringstream stdin_stream; std::stringstream stdin_stream;
//TODO: when debian stable gets newer g++ version that supports move on streams, remove unique_ptr below //TODO: when debian stable gets newer g++ version that supports move on streams, remove unique_ptr below
std::unique_ptr<std::stringstream> stdout_stream(new std::stringstream()); auto stdout_stream=std::make_unique<std::stringstream>();
auto command=Config::get().project.ctags_command+exclude+" --fields=ns --sort=foldcase -I \"override noexcept\" -f - -R *"; auto command=Config::get().project.ctags_command+exclude+" --fields=ns --sort=foldcase -I \"override noexcept\" -f - -R *";
Terminal::get().process(stdin_stream, *stdout_stream, command, run_path); Terminal::get().process(stdin_stream, *stdout_stream, command, run_path);
return {run_path, std::move(stdout_stream)}; return {run_path, std::move(stdout_stream)};

8
src/debug_lldb.cc

@ -45,8 +45,8 @@ void Debug::LLDB::start(const std::string &command, const boost::filesystem::pat
const std::string &remote_host) { const std::string &remote_host) {
if(!debugger) { if(!debugger) {
lldb::SBDebugger::Initialize(); lldb::SBDebugger::Initialize();
debugger=std::unique_ptr<lldb::SBDebugger>(new lldb::SBDebugger(lldb::SBDebugger::Create(true, log, nullptr))); debugger=std::make_unique<lldb::SBDebugger>(lldb::SBDebugger::Create(true, log, nullptr));
listener=std::unique_ptr<lldb::SBListener>(new lldb::SBListener("juCi++ lldb listener")); listener=std::make_unique<lldb::SBListener>("juCi++ lldb listener");
} }
//Create executable string and argument array //Create executable string and argument array
@ -103,7 +103,7 @@ void Debug::LLDB::start(const std::string &command, const boost::filesystem::pat
lldb::SBError error; lldb::SBError error;
if(!remote_host.empty()) { if(!remote_host.empty()) {
auto connect_string="connect://"+remote_host; auto connect_string="connect://"+remote_host;
process = std::unique_ptr<lldb::SBProcess>(new lldb::SBProcess(target.ConnectRemote(*listener, connect_string.c_str(), "gdb-remote", error))); process = std::make_unique<lldb::SBProcess>(target.ConnectRemote(*listener, connect_string.c_str(), "gdb-remote", error));
if(error.Fail()) { if(error.Fail()) {
Terminal::get().async_print(std::string("Error (debug): ")+error.GetCString()+'\n', true); Terminal::get().async_print(std::string("Error (debug): ")+error.GetCString()+'\n', true);
if(callback) if(callback)
@ -128,7 +128,7 @@ void Debug::LLDB::start(const std::string &command, const boost::filesystem::pat
process->Continue(); process->Continue();
} }
else else
process = std::unique_ptr<lldb::SBProcess>(new lldb::SBProcess(target.Launch(*listener, argv, const_cast<const char**>(environ), nullptr, nullptr, nullptr, path.string().c_str(), lldb::eLaunchFlagNone, false, error))); process = std::make_unique<lldb::SBProcess>(target.Launch(*listener, argv, const_cast<const char**>(environ), nullptr, nullptr, nullptr, path.string().c_str(), lldb::eLaunchFlagNone, false, error));
if(error.Fail()) { if(error.Fail()) {
Terminal::get().async_print(std::string("Error (debug): ")+error.GetCString()+'\n', true); Terminal::get().async_print(std::string("Error (debug): ")+error.GetCString()+'\n', true);
if(callback) if(callback)

38
src/directories.cc

@ -552,7 +552,7 @@ void Directories::add_or_update_path(const boost::filesystem::path &dir_path, co
std::shared_ptr<Git::Repository> repository; std::shared_ptr<Git::Repository> repository;
try { try {
repository=Git::get().get_repository(dir_path); repository=Git::get_repository(dir_path);
} }
catch(const std::exception &) {} catch(const std::exception &) {}
@ -593,22 +593,18 @@ void Directories::add_or_update_path(const boost::filesystem::path &dir_path, co
directories[dir_path.string()]={row, monitor, repository, repository_connection}; directories[dir_path.string()]={row, monitor, repository, repository_connection};
} }
std::unique_ptr<Gtk::TreeNodeChildren> children; //Gtk::TreeNodeChildren is missing default constructor... Gtk::TreeNodeChildren children(row?row.children():tree_store->children());
if(row) if(children) {
children=std::unique_ptr<Gtk::TreeNodeChildren>(new Gtk::TreeNodeChildren(row.children())); if(children.begin()->get_value(column_record.path)=="")
else tree_store->erase(children.begin());
children=std::unique_ptr<Gtk::TreeNodeChildren>(new Gtk::TreeNodeChildren(tree_store->children()));
if(*children) {
if(children->begin()->get_value(column_record.path)=="")
tree_store->erase(children->begin());
} }
std::unordered_set<std::string> not_deleted; std::unordered_set<std::string> not_deleted;
boost::filesystem::directory_iterator end_it; boost::filesystem::directory_iterator end_it;
for(boost::filesystem::directory_iterator it(dir_path);it!=end_it;it++) { for(boost::filesystem::directory_iterator it(dir_path);it!=end_it;it++) {
auto filename=it->path().filename().string(); auto filename=it->path().filename().string();
bool already_added=false; bool already_added=false;
if(*children) { if(children) {
for(auto &child: *children) { for(auto &child: children) {
if(child->get_value(column_record.name)==filename) { if(child->get_value(column_record.name)==filename) {
not_deleted.emplace(filename); not_deleted.emplace(filename);
already_added=true; already_added=true;
@ -617,7 +613,7 @@ void Directories::add_or_update_path(const boost::filesystem::path &dir_path, co
} }
} }
if(!already_added) { if(!already_added) {
auto child = tree_store->append(*children); auto child = tree_store->append(children);
not_deleted.emplace(filename); not_deleted.emplace(filename);
child->set_value(column_record.name, filename); child->set_value(column_record.name, filename);
child->set_value(column_record.markup, Glib::Markup::escape_text(filename)); child->set_value(column_record.markup, Glib::Markup::escape_text(filename));
@ -638,8 +634,8 @@ void Directories::add_or_update_path(const boost::filesystem::path &dir_path, co
} }
} }
} }
if(*children) { if(children) {
for(auto it=children->begin();it!=children->end();) { for(auto it=children.begin();it!=children.end();) {
if(not_deleted.count(it->get_value(column_record.name))==0) { if(not_deleted.count(it->get_value(column_record.name))==0) {
it=tree_store->erase(it); it=tree_store->erase(it);
} }
@ -647,8 +643,8 @@ void Directories::add_or_update_path(const boost::filesystem::path &dir_path, co
it++; it++;
} }
} }
if(!*children) { if(!children) {
auto child=tree_store->append(*children); auto child=tree_store->append(children);
child->set_value(column_record.name, std::string("(empty)")); child->set_value(column_record.name, std::string("(empty)"));
child->set_value(column_record.markup, Glib::Markup::escape_text("(empty)")); child->set_value(column_record.markup, Glib::Markup::escape_text("(empty)"));
child->set_value(column_record.type, PathType::UNKNOWN); child->set_value(column_record.type, PathType::UNKNOWN);
@ -720,15 +716,11 @@ void Directories::colorize_path(const boost::filesystem::path &dir_path_, bool i
green.set_blue(normal_color.get_blue()+factor*(green.get_blue()-normal_color.get_blue())); green.set_blue(normal_color.get_blue()+factor*(green.get_blue()-normal_color.get_blue()));
do { do {
std::unique_ptr<Gtk::TreeNodeChildren> children; //Gtk::TreeNodeChildren is missing default constructor... Gtk::TreeNodeChildren children(it->second.row?it->second.row.children():tree_store->children());
if(it->second.row) if(!children)
children=std::unique_ptr<Gtk::TreeNodeChildren>(new Gtk::TreeNodeChildren(it->second.row.children()));
else
children=std::unique_ptr<Gtk::TreeNodeChildren>(new Gtk::TreeNodeChildren(tree_store->children()));
if(!*children)
return; return;
for(auto &child: *children) { for(auto &child: children) {
auto name=Glib::Markup::escape_text(child.get_value(column_record.name)); auto name=Glib::Markup::escape_text(child.get_value(column_record.name));
auto path=child.get_value(column_record.path); auto path=child.get_value(column_record.path);
Gdk::RGBA *color; Gdk::RGBA *color;

31
src/git.cc

@ -1,7 +1,9 @@
#include "git.h" #include "git.h"
#include <cstring> #include <cstring>
bool Git::initialized=false;
std::mutex Git::mutex; std::mutex Git::mutex;
std::unordered_map<std::string, std::pair<std::unique_ptr<Git::Repository>, size_t> > Git::repositories;
std::mutex Git::repositories_mutex; std::mutex Git::repositories_mutex;
std::string Git::Error::message() noexcept { std::string Git::Error::message() noexcept {
@ -179,23 +181,23 @@ Git::Repository::Status Git::Repository::get_status() {
Status status; Status status;
bool first=true; bool first=true;
std::unique_lock<std::mutex> status_saved_lock(saved_status_mutex, std::defer_lock); std::unique_lock<std::mutex> status_saved_lock(saved_status_mutex, std::defer_lock);
std::function<void(const char *path, STATUS status)> callback=[this, &status, &first, &status_saved_lock](const char *path_cstr, Git::Repository::STATUS status_enum) { std::function<void(const char *path, STATUS status)> callback=[this, &status, &first, &status_saved_lock](const char *path_cstr, STATUS status_enum) {
if(first) { if(first) {
status_saved_lock.lock(); status_saved_lock.lock();
first=false; first=false;
} }
boost::filesystem::path rel_path(path_cstr); boost::filesystem::path rel_path(path_cstr);
do { do {
if(status_enum==Git::Repository::STATUS::MODIFIED) if(status_enum==STATUS::MODIFIED)
status.modified.emplace((work_path/rel_path).generic_string()); status.modified.emplace((work_path/rel_path).generic_string());
if(status_enum==Git::Repository::STATUS::NEW) if(status_enum==STATUS::NEW)
status.added.emplace((work_path/rel_path).generic_string()); status.added.emplace((work_path/rel_path).generic_string());
rel_path=rel_path.parent_path(); rel_path=rel_path.parent_path();
} while(!rel_path.empty()); } while(!rel_path.empty());
}; };
Error error; Error error;
std::lock_guard<std::mutex> lock(mutex); std::lock_guard<std::mutex> lock(mutex);
error.code = git_status_foreach(repository.get(), Repository::status_callback, &callback); error.code = git_status_foreach(repository.get(), status_callback, &callback);
if(error) if(error)
throw std::runtime_error(error.message()); throw std::runtime_error(error.message());
saved_status=status; saved_status=status;
@ -222,7 +224,8 @@ boost::filesystem::path Git::Repository::get_path() noexcept {
return Git::path(git_repository_path(repository.get())); return Git::path(git_repository_path(repository.get()));
} }
boost::filesystem::path Git::Repository::root_path(const boost::filesystem::path &path) { boost::filesystem::path Git::Repository::get_root_path(const boost::filesystem::path &path) {
initialize();
git_buf root = {0, 0, 0}; git_buf root = {0, 0, 0};
{ {
Error error; Error error;
@ -241,7 +244,8 @@ Git::Repository::Diff Git::Repository::get_diff(const boost::filesystem::path &p
return Diff(path, repository.get()); return Diff(path, repository.get());
} }
Git::Git() : repositories(new std::unordered_map<std::string, std::pair<std::unique_ptr<Repository>, size_t> >()) { void Git::initialize() noexcept {
std::lock_guard<std::mutex> lock(mutex);
if(!initialized) { if(!initialized) {
#if LIBGIT2_SOVERSION>=22 #if LIBGIT2_SOVERSION>=22
git_libgit2_init(); git_libgit2_init();
@ -253,24 +257,25 @@ Git::Git() : repositories(new std::unordered_map<std::string, std::pair<std::uni
} }
std::shared_ptr<Git::Repository> Git::get_repository(const boost::filesystem::path &path) { std::shared_ptr<Git::Repository> Git::get_repository(const boost::filesystem::path &path) {
initialize();
std::lock_guard<std::mutex> lock(repositories_mutex); std::lock_guard<std::mutex> lock(repositories_mutex);
auto root_path=std::make_shared<std::string>(Repository::root_path(path).generic_string()); auto root_path=std::make_shared<std::string>(Repository::get_root_path(path).generic_string());
auto it=repositories->find(*root_path); auto it=repositories.find(*root_path);
Repository *repository_ptr; Repository *repository_ptr;
if(it!=repositories->end()) { if(it!=repositories.end()) {
it->second.second++; it->second.second++;
repository_ptr=it->second.first.get(); repository_ptr=it->second.first.get();
} }
else { else {
it=repositories->emplace(*root_path, std::pair<std::unique_ptr<Repository>, size_t>(std::unique_ptr<Repository>(new Repository(*root_path)), 1)).first; it=repositories.emplace(*root_path, std::make_pair(std::unique_ptr<Repository>(new Repository(*root_path)), 1)).first;
repository_ptr=it->second.first.get(); repository_ptr=it->second.first.get();
} }
return std::shared_ptr<Repository>(repository_ptr, [this, root_path](Repository *) { return std::shared_ptr<Repository>(repository_ptr, [root_path](Repository *) {
std::lock_guard<std::mutex> lock(repositories_mutex); std::lock_guard<std::mutex> lock(repositories_mutex);
auto it=repositories->find(*root_path); auto it=repositories.find(*root_path);
it->second.second--; it->second.second--;
if(it->second.second==0) if(it->second.second==0)
repositories->erase(it); repositories.erase(it);
}); });
} }

19
src/git.h

@ -11,6 +11,7 @@
#include <boost/filesystem.hpp> #include <boost/filesystem.hpp>
class Git { class Git {
friend class Repository;
public: public:
class Error { class Error {
friend class Git; friend class Git;
@ -74,7 +75,7 @@ public:
boost::filesystem::path get_work_path() noexcept; boost::filesystem::path get_work_path() noexcept;
boost::filesystem::path get_path() noexcept; boost::filesystem::path get_path() noexcept;
static boost::filesystem::path root_path(const boost::filesystem::path &path); static boost::filesystem::path get_root_path(const boost::filesystem::path &path);
Diff get_diff(const boost::filesystem::path &path); Diff get_diff(const boost::filesystem::path &path);
@ -82,21 +83,19 @@ public:
}; };
private: private:
static bool initialized;
///Mutex for thread safe operations ///Mutex for thread safe operations
static std::mutex mutex; static std::mutex mutex;
bool initialized=false;
std::unordered_map<std::string, std::pair<std::unique_ptr<Repository>, size_t> > *repositories; //Freed by OS at program exit static std::unordered_map<std::string, std::pair<std::unique_ptr<Git::Repository>, size_t> > repositories;
static std::mutex repositories_mutex; static std::mutex repositories_mutex;
Git(); ///Call initialize in public static methods
static void initialize() noexcept;
static boost::filesystem::path path(const char *cpath, size_t cpath_length=static_cast<size_t>(-1)) noexcept; static boost::filesystem::path path(const char *cpath, size_t cpath_length=static_cast<size_t>(-1)) noexcept;
public: public:
static Git &get() noexcept { static std::shared_ptr<Repository> get_repository(const boost::filesystem::path &path);
static Git instance;
return instance;
}
std::shared_ptr<Repository> get_repository(const boost::filesystem::path &path);
}; };
#endif //JUCI_GIT_H_ #endif //JUCI_GIT_H_

4
src/project.cc

@ -412,7 +412,7 @@ void Project::Clang::debug_backtrace() {
auto backtrace=Debug::LLDB::get().get_backtrace(); auto backtrace=Debug::LLDB::get().get_backtrace();
auto iter=view->get_iter_for_dialog(); auto iter=view->get_iter_for_dialog();
view->selection_dialog=std::unique_ptr<SelectionDialog>(new SelectionDialog(*view, view->get_buffer()->create_mark(iter), true, true)); view->selection_dialog=std::make_unique<SelectionDialog>(*view, view->get_buffer()->create_mark(iter), true, true);
auto rows=std::make_shared<std::unordered_map<std::string, Debug::LLDB::Frame> >(); auto rows=std::make_shared<std::unordered_map<std::string, Debug::LLDB::Frame> >();
if(backtrace.size()==0) if(backtrace.size()==0)
return; return;
@ -462,7 +462,7 @@ void Project::Clang::debug_show_variables() {
auto variables=Debug::LLDB::get().get_variables(); auto variables=Debug::LLDB::get().get_variables();
auto iter=view->get_iter_for_dialog(); auto iter=view->get_iter_for_dialog();
view->selection_dialog=std::unique_ptr<SelectionDialog>(new SelectionDialog(*view, view->get_buffer()->create_mark(iter), true, true)); view->selection_dialog=std::make_unique<SelectionDialog>(*view, view->get_buffer()->create_mark(iter), true, true);
auto rows=std::make_shared<std::unordered_map<std::string, Debug::LLDB::Variable> >(); auto rows=std::make_shared<std::unordered_map<std::string, Debug::LLDB::Variable> >();
if(variables.size()==0) if(variables.size()==0)
return; return;

2
src/project_build.cc

@ -6,7 +6,7 @@ std::unique_ptr<Project::Build> Project::Build::create(const boost::filesystem::
if(!cmake->project_path.empty()) if(!cmake->project_path.empty())
return cmake; return cmake;
else else
return std::unique_ptr<Project::Build>(new Project::Build()); return std::make_unique<Project::Build>();
} }
boost::filesystem::path Project::Build::get_default_path() { boost::filesystem::path Project::Build::get_default_path() {

6
src/source_clang.cc

@ -104,7 +104,7 @@ void Source::ClangViewParse::parse_initialize() {
} }
pos++; pos++;
} }
clang_tu = std::unique_ptr<clang::TranslationUnit>(new clang::TranslationUnit(clang_index, file_path.string(), get_compilation_commands(), buffer.raw())); clang_tu = std::make_unique<clang::TranslationUnit>(clang_index, file_path.string(), get_compilation_commands(), buffer.raw());
clang_tokens=clang_tu->get_tokens(0, buffer.bytes()-1); clang_tokens=clang_tu->get_tokens(0, buffer.bytes()-1);
update_syntax(); update_syntax();
@ -539,7 +539,7 @@ void Source::ClangViewAutocomplete::autocomplete_dialog_setup() {
auto start_iter=get_buffer()->get_insert()->get_iter(); auto start_iter=get_buffer()->get_insert()->get_iter();
if(prefix.size()>0 && !start_iter.backward_chars(prefix.size())) if(prefix.size()>0 && !start_iter.backward_chars(prefix.size()))
return; return;
autocomplete_dialog=std::unique_ptr<CompletionDialog>(new CompletionDialog(*this, get_buffer()->create_mark(start_iter))); autocomplete_dialog=std::make_unique<CompletionDialog>(*this, get_buffer()->create_mark(start_iter));
autocomplete_dialog_rows.clear(); autocomplete_dialog_rows.clear();
autocomplete_dialog->on_hide=[this](){ autocomplete_dialog->on_hide=[this](){
get_buffer()->end_user_action(); get_buffer()->end_user_action();
@ -1315,7 +1315,7 @@ void Source::ClangViewRefactor::wait_parsing(const std::vector<Source::View*> &v
if(!clang_view->parsed) { if(!clang_view->parsed) {
clang_views.emplace_back(clang_view); clang_views.emplace_back(clang_view);
if(!message) if(!message)
message=std::unique_ptr<Dialog::Message>(new Dialog::Message("Please wait while all buffers finish parsing")); message=std::make_unique<Dialog::Message>("Please wait while all buffers finish parsing");
} }
} }
} }

4
src/source_diff.cc

@ -98,7 +98,7 @@ void Source::DiffView::configure() {
return; return;
try { try {
repository=Git::get().get_repository(this->file_path.parent_path()); repository=Git::get_repository(this->file_path.parent_path());
} }
catch(const std::exception &) { catch(const std::exception &) {
return; return;
@ -308,7 +308,7 @@ std::unique_ptr<Git::Repository::Diff> Source::DiffView::get_diff() {
if(relative_path.empty()) if(relative_path.empty())
throw std::runtime_error("not a relative path"); throw std::runtime_error("not a relative path");
} }
return std::unique_ptr<Git::Repository::Diff>(new Git::Repository::Diff(repository->get_diff(relative_path))); return std::make_unique<Git::Repository::Diff>(repository->get_diff(relative_path));
} }
void Source::DiffView::update_lines() { void Source::DiffView::update_lines() {

2
src/source_spellcheck.cc

@ -148,7 +148,7 @@ Source::SpellCheckView::SpellCheckView() : Gsv::View() {
} }
} }
if(need_suggestions) { if(need_suggestions) {
spellcheck_suggestions_dialog=std::unique_ptr<SelectionDialog>(new SelectionDialog(*this, get_buffer()->create_mark(get_buffer()->get_insert()->get_iter()), false)); spellcheck_suggestions_dialog=std::make_unique<SelectionDialog>(*this, get_buffer()->create_mark(get_buffer()->get_insert()->get_iter()), false);
auto word=spellcheck_get_word(get_buffer()->get_insert()->get_iter()); auto word=spellcheck_get_word(get_buffer()->get_insert()->get_iter());
auto suggestions=spellcheck_get_suggestions(word.first, word.second); auto suggestions=spellcheck_get_suggestions(word.first, word.second);
if(suggestions.size()==0) if(suggestions.size()==0)

10
src/terminal.cc

@ -59,13 +59,13 @@ Terminal::Terminal() {
int Terminal::process(const std::string &command, const boost::filesystem::path &path, bool use_pipes) { int Terminal::process(const std::string &command, const boost::filesystem::path &path, bool use_pipes) {
std::unique_ptr<Process> process; std::unique_ptr<Process> process;
if(use_pipes) if(use_pipes)
process=std::unique_ptr<Process>(new Process(command, path.string(), [this](const char* bytes, size_t n) { process=std::make_unique<Process>(command, path.string(), [this](const char* bytes, size_t n) {
async_print(std::string(bytes, n)); async_print(std::string(bytes, n));
}, [this](const char* bytes, size_t n) { }, [this](const char* bytes, size_t n) {
async_print(std::string(bytes, n), true); async_print(std::string(bytes, n), true);
})); });
else else
process=std::unique_ptr<Process>(new Process(command, path.string())); process=std::make_unique<Process>(command, path.string());
if(process->get_id()<=0) { if(process->get_id()<=0) {
async_print("Error: failed to run command: " + command + "\n", true); async_print("Error: failed to run command: " + command + "\n", true);
@ -113,11 +113,11 @@ void Terminal::async_process(const std::string &command, const boost::filesystem
std::thread async_execute_thread([this, command, path, callback](){ std::thread async_execute_thread([this, command, path, callback](){
std::unique_lock<std::mutex> processes_lock(processes_mutex); std::unique_lock<std::mutex> processes_lock(processes_mutex);
stdin_buffer.clear(); stdin_buffer.clear();
std::shared_ptr<Process> process(new Process(command, path.string(), [this](const char* bytes, size_t n) { auto process=std::make_shared<Process>(command, path.string(), [this](const char* bytes, size_t n) {
async_print(std::string(bytes, n)); async_print(std::string(bytes, n));
}, [this](const char* bytes, size_t n) { }, [this](const char* bytes, size_t n) {
async_print(std::string(bytes, n), true); async_print(std::string(bytes, n), true);
}, true)); }, true);
auto pid=process->get_id(); auto pid=process->get_id();
if (pid<=0) { if (pid<=0) {
processes_lock.unlock(); processes_lock.unlock();

4
src/tooltips.cc

@ -46,7 +46,7 @@ void Tooltip::update() {
void Tooltip::show(bool disregard_drawn) { void Tooltip::show(bool disregard_drawn) {
if(!window) { if(!window) {
//init window //init window
window=std::unique_ptr<Gtk::Window>(new Gtk::Window(Gtk::WindowType::WINDOW_POPUP)); window=std::make_unique<Gtk::Window>(Gtk::WindowType::WINDOW_POPUP);
auto g_application=g_application_get_default(); auto g_application=g_application_get_default();
auto gio_application=Glib::wrap(g_application, true); auto gio_application=Glib::wrap(g_application, true);
@ -61,7 +61,7 @@ void Tooltip::show(bool disregard_drawn) {
window->set_skip_taskbar_hint(true); window->set_skip_taskbar_hint(true);
window->set_default_size(0, 0); window->set_default_size(0, 0);
tooltip_widget=std::unique_ptr<Gtk::TextView>(new Gtk::TextView(create_tooltip_buffer())); tooltip_widget=std::make_unique<Gtk::TextView>(create_tooltip_buffer());
wrap_lines(tooltip_widget->get_buffer()); wrap_lines(tooltip_widget->get_buffer());
tooltip_widget->set_editable(false); tooltip_widget->set_editable(false);
auto tag=text_view.get_buffer()->get_tag_table()->lookup("def:note_background"); auto tag=text_view.get_buffer()->get_tag_table()->lookup("def:note_background");

8
src/window.cc

@ -452,7 +452,7 @@ void Window::set_menu_actions() {
stream->seekg(0, std::ios::beg); stream->seekg(0, std::ios::beg);
auto dialog_iter=view->get_iter_for_dialog(); auto dialog_iter=view->get_iter_for_dialog();
view->selection_dialog=std::unique_ptr<SelectionDialog>(new SelectionDialog(*view, view->get_buffer()->create_mark(dialog_iter), true, true)); view->selection_dialog=std::make_unique<SelectionDialog>(*view, view->get_buffer()->create_mark(dialog_iter), true, true);
auto rows=std::make_shared<std::unordered_map<std::string, Source::Offset> >(); auto rows=std::make_shared<std::unordered_map<std::string, Source::Offset> >();
std::string line; std::string line;
@ -551,7 +551,7 @@ void Window::set_menu_actions() {
auto locations=view->get_implementation_locations(Notebook::get().get_views()); auto locations=view->get_implementation_locations(Notebook::get().get_views());
if(!locations.empty()) { if(!locations.empty()) {
auto dialog_iter=view->get_iter_for_dialog(); auto dialog_iter=view->get_iter_for_dialog();
view->selection_dialog=std::unique_ptr<SelectionDialog>(new SelectionDialog(*view, view->get_buffer()->create_mark(dialog_iter), true, true)); view->selection_dialog=std::make_unique<SelectionDialog>(*view, view->get_buffer()->create_mark(dialog_iter), true, true);
auto rows=std::make_shared<std::unordered_map<std::string, Source::Offset> >(); auto rows=std::make_shared<std::unordered_map<std::string, Source::Offset> >();
auto project_path=Project::Build::create(view->file_path)->project_path; auto project_path=Project::Build::create(view->file_path)->project_path;
if(project_path.empty()) { if(project_path.empty()) {
@ -608,7 +608,7 @@ void Window::set_menu_actions() {
auto usages=view->get_usages(Notebook::get().get_views()); auto usages=view->get_usages(Notebook::get().get_views());
if(!usages.empty()) { if(!usages.empty()) {
auto dialog_iter=view->get_iter_for_dialog(); auto dialog_iter=view->get_iter_for_dialog();
view->selection_dialog=std::unique_ptr<SelectionDialog>(new SelectionDialog(*view, view->get_buffer()->create_mark(dialog_iter), true, true)); view->selection_dialog=std::make_unique<SelectionDialog>(*view, view->get_buffer()->create_mark(dialog_iter), true, true);
auto rows=std::make_shared<std::unordered_map<std::string, Source::Offset> >(); auto rows=std::make_shared<std::unordered_map<std::string, Source::Offset> >();
auto iter=view->get_buffer()->get_insert()->get_iter(); auto iter=view->get_buffer()->get_insert()->get_iter();
@ -658,7 +658,7 @@ void Window::set_menu_actions() {
auto methods=Notebook::get().get_current_view()->get_methods(); auto methods=Notebook::get().get_current_view()->get_methods();
if(!methods.empty()) { if(!methods.empty()) {
auto dialog_iter=view->get_iter_for_dialog(); auto dialog_iter=view->get_iter_for_dialog();
view->selection_dialog=std::unique_ptr<SelectionDialog>(new SelectionDialog(*view, view->get_buffer()->create_mark(dialog_iter), true, true)); view->selection_dialog=std::make_unique<SelectionDialog>(*view, view->get_buffer()->create_mark(dialog_iter), true, true);
auto rows=std::make_shared<std::unordered_map<std::string, Source::Offset> >(); auto rows=std::make_shared<std::unordered_map<std::string, Source::Offset> >();
auto iter=view->get_buffer()->get_insert()->get_iter(); auto iter=view->get_buffer()->get_insert()->get_iter();
for(auto &method: methods) { for(auto &method: methods) {

4
tests/git_test.cc

@ -11,7 +11,7 @@ int main() {
auto git_path=jucipp_path/".git"; auto git_path=jucipp_path/".git";
try { try {
auto repository=Git::get().get_repository(tests_path); auto repository=Git::get_repository(tests_path);
g_assert(repository->get_path()==git_path); g_assert(repository->get_path()==git_path);
g_assert(repository->get_work_path()==jucipp_path); g_assert(repository->get_work_path()==jucipp_path);
@ -30,7 +30,7 @@ int main() {
} }
try { try {
g_assert(Git::Repository::root_path(tests_path)==git_path); g_assert(Git::Repository::get_root_path(tests_path)==git_path);
} }
catch(const std::exception &e) { catch(const std::exception &e) {
std::cerr << e.what() << std::endl; std::cerr << e.what() << std::endl;

Loading…
Cancel
Save