Browse Source

Fixed crash if going to a declaration in a changed file that is not saved.

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

22
src/window.cc

@ -363,11 +363,23 @@ void Window::create_menu() {
auto location=notebook.get_current_view()->get_declaration_location(); auto location=notebook.get_current_view()->get_declaration_location();
if(location.first.size()>0) { if(location.first.size()>0) {
notebook.open(location.first); notebook.open(location.first);
notebook.get_current_view()->get_buffer()->place_cursor(notebook.get_current_view()->get_buffer()->get_iter_at_line_index(location.second.line-1, location.second.index-1)); auto line=static_cast<int>(location.second.line)-1;
while(gtk_events_pending()) auto index=static_cast<int>(location.second.index)-1;
gtk_main_iteration(); auto buffer=notebook.get_current_view()->get_buffer();
if(notebook.get_current_page()!=-1) line=std::min(line, buffer->get_line_count()-1);
notebook.get_current_view()->scroll_to(notebook.get_current_view()->get_buffer()->get_insert(), 0.0, 1.0, 0.5); if(line>=0) {
auto iter=buffer->get_iter_at_line(line);
while(!iter.ends_line())
iter.forward_char();
auto end_line_index=iter.get_line_index();
index=std::min(index, end_line_index);
buffer->place_cursor(buffer->get_iter_at_line_index(line, index));
while(gtk_events_pending())
gtk_main_iteration();
if(notebook.get_current_page()!=-1)
notebook.get_current_view()->scroll_to(notebook.get_current_view()->get_buffer()->get_insert(), 0.0, 1.0, 0.5);
}
} }
} }
} }

Loading…
Cancel
Save