[ghex] Fix revert for mmapBuf; other UI tweaks.
- From: Logan Rathbone <larathbone src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ghex] Fix revert for mmapBuf; other UI tweaks.
- Date: Mon, 20 Dec 2021 23:43:01 +0000 (UTC)
commit abbf1773ef906040221c6aa2f20d93bf00cd3749
Author: Logan Rathbone <poprocks gmail com>
Date: Mon Dec 20 16:54:02 2021 -0500
Fix revert for mmapBuf; other UI tweaks.
src/ghex-application-window.c | 14 +++++++-------
src/gtkhex.c | 3 +--
src/hex-buffer-mmap.c | 15 +++++++++++++++
src/hex-document.c | 1 -
4 files changed, 23 insertions(+), 10 deletions(-)
---
diff --git a/src/ghex-application-window.c b/src/ghex-application-window.c
index c8ca6b6..09edbab 100644
--- a/src/ghex-application-window.c
+++ b/src/ghex-application-window.c
@@ -146,11 +146,14 @@ static void ghex_application_window_remove_tab (GHexApplicationWindow *self,
GHexNotebookTab *tab);
static GHexNotebookTab * ghex_application_window_get_current_tab (GHexApplicationWindow *self);
-static void set_statusbar(GHexApplicationWindow *self, const char *str);
+static void set_statusbar (GHexApplicationWindow *self, const char *str);
static void update_status_message (GHexApplicationWindow *self);
static void update_gui_data (GHexApplicationWindow *self);
static gboolean assess_can_save (HexDocument *doc);
+static void doc_read_ready_cb (GObject *source_object, GAsyncResult *res,
+ gpointer user_data);
+
/* GHexApplicationWindow -- PRIVATE FUNCTIONS */
/* Common macro to apply something to the 'gh' of each tab of the notebook.
@@ -1135,10 +1138,9 @@ revert_response_cb (GtkDialog *dialog,
doc = gtk_hex_get_document (ACTIVE_GH);
+ extra_user_data = ACTIVE_GH;
show_doc_loading_spinner (self);
-
- /* FIXME - error handling */
- hex_document_read_async (doc, NULL, NULL, NULL);
+ hex_document_read_async (doc, NULL, doc_read_ready_cb, self);
end:
gtk_window_destroy (GTK_WINDOW(dialog));
@@ -2045,7 +2047,7 @@ do_nag_screen (GHexApplicationWindow *self)
}
#endif
-
+/* also takes extra_user_data ! Hooray for cheap shortcuts! */
static void
doc_read_ready_cb (GObject *source_object,
GAsyncResult *res,
@@ -2086,8 +2088,6 @@ doc_read_ready_cb (GObject *source_object,
extra_user_data = NULL;
}
-
-
void
ghex_application_window_open_file (GHexApplicationWindow *self, GFile *file)
{
diff --git a/src/gtkhex.c b/src/gtkhex.c
index 53bae30..d3e6f61 100644
--- a/src/gtkhex.c
+++ b/src/gtkhex.c
@@ -2328,8 +2328,7 @@ gtk_hex_dispose (GObject *object)
g_clear_object (&gh->alayout);
g_clear_object (&gh->olayout);
- g_object_unref (gh->document);
-// g_clear_object (&gh->document);
+ g_clear_object (&gh->document);
/* Chain up */
G_OBJECT_CLASS(gtk_hex_parent_class)->dispose(object);
diff --git a/src/hex-buffer-mmap.c b/src/hex-buffer-mmap.c
index d813bc1..f3dc99f 100644
--- a/src/hex-buffer-mmap.c
+++ b/src/hex-buffer-mmap.c
@@ -521,6 +521,20 @@ create_fd_from_path (HexBufferMmap *self, const char *path)
return fd;
}
+static void
+clear_buffer (HexBufferMmap *self)
+{
+ if (self->fd)
+ {
+ close (self->fd);
+ clear_tmpfile_path (self);
+ }
+ if (self->data)
+ munmap (self->data, self->mapped);
+
+ self->payload = self->mapped = self->gap = 0;
+}
+
static gboolean
create_buffer (HexBufferMmap *self)
{
@@ -592,6 +606,7 @@ hex_buffer_mmap_read (HexBuffer *buf)
self->clean = p;
/* Create dirty buffer for writing etc. */
+ clear_buffer (self);
create_buffer (self);
/* FIXME/TODO - sanity check against # of bytes read? */
diff --git a/src/hex-document.c b/src/hex-document.c
index 31a9f8e..24c9885 100644
--- a/src/hex-document.c
+++ b/src/hex-document.c
@@ -474,7 +474,6 @@ hex_document_read_finish (HexDocument *doc,
return g_task_propagate_boolean (G_TASK (result), error);
}
-
static void
document_ready_cb (GObject *source_object,
GAsyncResult *res,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]