Commit 864a83fc authored by Jim Nelson's avatar Jim Nelson

Fixed a bug where a month event page was triggering an assertion when accessed...

Fixed a bug where a month event page was triggering an assertion when accessed immediately after it was created 
by an import.  This was due to Gtk.Notebook.show_all() not being called after the page was added to the notebook 
(which is a no-no).  This fixes it, and hopefully ensures it's always called when a page is added.
parent 0478f27b
...@@ -159,14 +159,14 @@ public class Event : EventSource { ...@@ -159,14 +159,14 @@ public class Event : EventSource {
global.add(current_event); global.add(current_event);
debug("Reported event creation %s", current_event.to_string()); debug("Added event %s to global collection", current_event.to_string());
} }
current_event_start = exposure_time; current_event_start = exposure_time;
current_event = new Event( current_event = new Event(
event_table.create(photo.get_photo_id(), current_event_start)); event_table.create(photo.get_photo_id(), current_event_start));
debug("Created event %s", current_event.to_string()); debug("Created new event %s", current_event.to_string());
} }
assert(current_event != null); assert(current_event != null);
...@@ -186,7 +186,7 @@ public class Event : EventSource { ...@@ -186,7 +186,7 @@ public class Event : EventSource {
global.add(current_event); global.add(current_event);
debug("Created event %s", current_event.to_string()); debug("Added event %s to global collection", current_event.to_string());
} }
} }
......
...@@ -100,7 +100,6 @@ public class LibraryWindow : AppWindow { ...@@ -100,7 +100,6 @@ public class LibraryWindow : AppWindow {
// add this to the notebook and tell the notebook to show it (as per DevHelp) // add this to the notebook and tell the notebook to show it (as per DevHelp)
LibraryWindow.get_app().add_to_notebook(page); LibraryWindow.get_app().add_to_notebook(page);
LibraryWindow.get_app().notebook.show_all();
} }
return page; return page;
...@@ -678,14 +677,14 @@ public class LibraryWindow : AppWindow { ...@@ -678,14 +677,14 @@ public class LibraryWindow : AppWindow {
sidebar.insert_child_sorted(events_directory_page.get_marker(), year, comparator); sidebar.insert_child_sorted(events_directory_page.get_marker(), year, comparator);
LibraryWindow.get_app().add_to_notebook(year); add_to_notebook(year);
events_dir_list.add(year); events_dir_list.add(year);
} }
sidebar.insert_child_sorted(year.get_marker(), month, comparator); sidebar.insert_child_sorted(year.get_marker(), month, comparator);
LibraryWindow.get_app().add_to_notebook(month); add_to_notebook(month);
events_dir_list.add(month); events_dir_list.add(month);
...@@ -728,15 +727,10 @@ public class LibraryWindow : AppWindow { ...@@ -728,15 +727,10 @@ public class LibraryWindow : AppWindow {
private void remove_event_tree(SidebarPage page) { private void remove_event_tree(SidebarPage page) {
// remove from notebook // remove from notebook
if (page is SubEventsDirectoryPage || if (page is SubEventsDirectoryPage)
(page is EventPageProxy && ((EventPageProxy) page).has_page())) { remove_from_notebook((SubEventsDirectoryPage) page);
else if (page is EventPageProxy && ((EventPageProxy) page).has_page())
int pos = get_notebook_pos(((page is EventPageProxy) ? remove_from_notebook(((EventPageProxy) page).get_page());
((EventPageProxy) page).get_page() : (Page) page));
assert(pos >= 0);
notebook.remove_page(pos);
}
// grab parent page // grab parent page
SidebarPage parent = sidebar.get_parent_page(page); SidebarPage parent = sidebar.get_parent_page(page);
...@@ -794,6 +788,16 @@ public class LibraryWindow : AppWindow { ...@@ -794,6 +788,16 @@ public class LibraryWindow : AppWindow {
int pos = notebook.append_page(page.get_layout(), null); int pos = notebook.append_page(page.get_layout(), null);
assert(pos >= 0); assert(pos >= 0);
// need to show_all() after pages are added and removed
notebook.show_all();
}
private void remove_from_notebook(Page page) {
notebook.remove_page(get_notebook_pos(page));
// need to show_all() after pages are added and removed
notebook.show_all();
} }
private int get_notebook_pos(Page page) { private int get_notebook_pos(Page page) {
...@@ -807,32 +811,24 @@ public class LibraryWindow : AppWindow { ...@@ -807,32 +811,24 @@ public class LibraryWindow : AppWindow {
add_to_notebook(parent); add_to_notebook(parent);
sidebar.add_parent(parent); sidebar.add_parent(parent);
notebook.show_all();
} }
private void add_child_page(SidebarMarker parent_marker, Page child) { private void add_child_page(SidebarMarker parent_marker, Page child) {
add_to_notebook(child); add_to_notebook(child);
sidebar.add_child(parent_marker, child); sidebar.add_child(parent_marker, child);
notebook.show_all();
} }
private void insert_page_after(SidebarMarker after_marker, Page page) { private void insert_page_after(SidebarMarker after_marker, Page page) {
add_to_notebook(page); add_to_notebook(page);
sidebar.insert_sibling_after(after_marker, page); sidebar.insert_sibling_after(after_marker, page);
notebook.show_all();
} }
// an orphan page is a Page that exists in the notebook (and can therefore be switched to) but // an orphan page is a Page that exists in the notebook (and can therefore be switched to) but
// is not listed in the sidebar // is not listed in the sidebar
private void add_orphan_page(Page orphan) { private void add_orphan_page(Page orphan) {
add_to_notebook(orphan); add_to_notebook(orphan);
notebook.show_all();
} }
private void remove_page(Page page) { private void remove_page(Page page) {
...@@ -859,10 +855,7 @@ public class LibraryWindow : AppWindow { ...@@ -859,10 +855,7 @@ public class LibraryWindow : AppWindow {
while (pages_to_be_removed.size > 0) { while (pages_to_be_removed.size > 0) {
Page page = pages_to_be_removed.get(0); Page page = pages_to_be_removed.get(0);
// remove from notebook remove_from_notebook(page);
int pos = get_notebook_pos(page);
assert(pos >= 0);
notebook.remove_page(pos);
// remove from sidebar, if present // remove from sidebar, if present
sidebar.remove_page(page); sidebar.remove_page(page);
...@@ -965,9 +958,7 @@ public class LibraryWindow : AppWindow { ...@@ -965,9 +958,7 @@ public class LibraryWindow : AppWindow {
unsubscribe_from_basic_information(get_current_page()); unsubscribe_from_basic_information(get_current_page());
} }
int pos = get_notebook_pos(page); notebook.set_current_page(get_notebook_pos(page));
if (pos >= 0)
notebook.set_current_page(pos);
// switch menus // switch menus
if (get_current_page() != null) if (get_current_page() != null)
......
...@@ -555,7 +555,7 @@ public abstract class CheckerboardPage : Page { ...@@ -555,7 +555,7 @@ public abstract class CheckerboardPage : Page {
base(page_name); base(page_name);
layout = new CheckerboardLayout(get_view()); layout = new CheckerboardLayout(get_view());
layout.set_name(name); layout.set_name(page_name);
set_event_source(layout); set_event_source(layout);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment