+static char *get_text(GtkTextBuffer *buffer)
+{
+ GtkTextIter start;
+ GtkTextIter end;
+
+ gtk_text_buffer_get_start_iter(buffer, &start);
+ gtk_text_buffer_get_end_iter(buffer, &end);
+ return gtk_text_buffer_get_text(buffer, &start, &end, FALSE);
+}
+
+void flush_dive_info_changes(void)
+{
+ struct dive *dive = buffered_dive;
+
+ if (!dive)
+ return;
+
+ if (location_changed) {
+ g_free(dive->location);
+ dive->location = get_text(location);
+ }
+
+ if (notes_changed) {
+ g_free(dive->notes);
+ dive->notes = get_text(notes);
+ }
+}
+