Browse Source

Removed dangerous use of vector<const char*>. Opening files in a project now work every time.

merge-requests/365/head
eidheim 11 years ago
parent
commit
872a61beb7
  1. 8
      juci/source.cc
  2. 2
      juci/source.h

8
juci/source.cc

@ -115,7 +115,7 @@ InitSyntaxHighlighting(const std::string &filepath,
int end_offset, int end_offset,
clang::Index *index) { clang::Index *index) {
set_project_path(project_path); set_project_path(project_path);
std::vector<const char*> arguments = get_compilation_commands(); std::vector<string> arguments = get_compilation_commands();
tu_ = clang::TranslationUnit(index, tu_ = clang::TranslationUnit(index,
filepath, filepath,
arguments, arguments,
@ -202,16 +202,16 @@ const Source::Config& Source::Model::config() const {
return config_; return config_;
} }
std::vector<const char*> Source::Model:: std::vector<std::string> Source::Model::
get_compilation_commands() { get_compilation_commands() {
clang::CompilationDatabase db(project_path()+"/"); clang::CompilationDatabase db(project_path()+"/");
clang::CompileCommands commands(file_path(), &db); clang::CompileCommands commands(file_path(), &db);
std::vector<clang::CompileCommand> cmds = commands.get_commands(); std::vector<clang::CompileCommand> cmds = commands.get_commands();
std::vector<const char*> arguments; std::vector<std::string> arguments;
for (auto &i : cmds) { for (auto &i : cmds) {
std::vector<std::string> lol = i.get_command_as_args(); std::vector<std::string> lol = i.get_command_as_args();
for (int a = 1; a < lol.size()-4; a++) { for (int a = 1; a < lol.size()-4; a++) {
arguments.emplace_back(lol[a].c_str()); arguments.emplace_back(lol[a]);
} }
} }
return arguments; return arguments;

2
juci/source.h

@ -135,7 +135,7 @@ namespace Source {
int token_kind); int token_kind);
void HighlightCursor(clang::Token *token, void HighlightCursor(clang::Token *token,
std::vector<Range> *source_ranges); std::vector<Range> *source_ranges);
std::vector<const char*> get_compilation_commands(); std::vector<std::string> get_compilation_commands();
}; };
class Controller { class Controller {

Loading…
Cancel
Save