Browse Source

Fixed crash when using go to line after closing all the tabs.

merge-requests/365/head
eidheim 10 years ago
parent
commit
eb887d723d
  1. 16
      src/window.cc

16
src/window.cc

@ -497,21 +497,21 @@ void Window::goto_line_entry() {
entry_box.clear(); entry_box.clear();
if(notebook.get_current_page()!=-1) { if(notebook.get_current_page()!=-1) {
entry_box.entries.emplace_back("", [this](const std::string& content){ entry_box.entries.emplace_back("", [this](const std::string& content){
auto buffer=notebook.get_current_view()->get_buffer(); if(notebook.get_current_page()!=-1) {
try { auto buffer=notebook.get_current_view()->get_buffer();
auto line=stoul(content); try {
if(line>0 && (int)line<=buffer->get_line_count()) { auto line=stoul(content);
line--; if(line>0 && (int)line<=buffer->get_line_count()) {
if(notebook.get_current_page()!=-1) { line--;
buffer->place_cursor(buffer->get_iter_at_line(line)); buffer->place_cursor(buffer->get_iter_at_line(line));
while(gtk_events_pending()) while(gtk_events_pending())
gtk_main_iteration(); gtk_main_iteration();
notebook.get_current_view()->scroll_to(buffer->get_insert(), 0.0, 1.0, 0.5); notebook.get_current_view()->scroll_to(buffer->get_insert(), 0.0, 1.0, 0.5);
} }
} }
catch(const std::exception &e) {}
entry_box.hide();
} }
catch(const std::exception &e) {}
entry_box.hide();
}); });
auto entry_it=entry_box.entries.begin(); auto entry_it=entry_box.entries.begin();
entry_box.buttons.emplace_back("Go to line", [this, entry_it](){ entry_box.buttons.emplace_back("Go to line", [this, entry_it](){

Loading…
Cancel
Save