From a180682eb2c942068c0eb71d2bed9007f2702c0a Mon Sep 17 00:00:00 2001 From: eidheim Date: Sun, 14 Jun 2015 16:00:59 +0200 Subject: [PATCH] Now, undo does not go back to when textbuffer was empty. Fixed crash when closing tabs while processing source. --- juci/source.cc | 7 +++++++ juci/source.h | 1 + 2 files changed, 8 insertions(+) diff --git a/juci/source.cc b/juci/source.cc index 1943959..ff018e5 100644 --- a/juci/source.cc +++ b/juci/source.cc @@ -286,6 +286,11 @@ Source::Controller::Controller(const Source::Config &config, view().signal_key_press_event().connect(sigc::mem_fun(*this, &Source::Controller::OnKeyPress), false); } +Source::Controller::~Controller() { + parsing.lock(); //Be sure not to destroy while still parsing with libclang + parsing.unlock(); +} + // Source::Controller::view() // return shared_ptr to the view Source::View& Source::Controller::view() { @@ -345,7 +350,9 @@ void Source::Controller::OnOpenFile(const string &filepath) { std::map buffers; notebook_->MapBuffers(&buffers); buffers[filepath] = s.get_content(); + buffer()->get_undo_manager()->begin_not_undoable_action(); buffer()->set_text(s.get_content()); + buffer()->get_undo_manager()->end_not_undoable_action(); int start_offset = buffer()->begin().get_offset(); int end_offset = buffer()->end().get_offset(); if (notebook_->LegalExtension(filepath.substr(filepath.find_last_of(".") + 1))) { diff --git a/juci/source.h b/juci/source.h index c18e525..083fd30 100644 --- a/juci/source.h +++ b/juci/source.h @@ -143,6 +143,7 @@ namespace Source { Controller(const Source::Config &config, Notebook::Controller *notebook); Controller(); + ~Controller(); View& view(); Model& model(); void OnNewEmptyFile();