After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 500358 - display doesn't update after calling gtk_hex_set_data
display doesn't update after calling gtk_hex_set_data
Status: RESOLVED FIXED
Product: ghex
Classification: Applications
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: Jaka Mocnik
Jaka Mocnik
Depends on:
Blocks: 395701
 
 
Reported: 2007-11-29 04:55 UTC by Jonathon Jongsma
Modified: 2007-12-20 04:21 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
test program (2.67 KB, text/plain)
2007-11-29 04:55 UTC, Jonathon Jongsma
  Details
[PATCH] Redraw GtkHex widget when the HexDocument changes (2.89 KB, patch)
2007-12-01 04:32 UTC, Jonathon Jongsma
none Details | Review
[PATCH] Redraw GtkHex widget when the HexDocument changes (Fix for bug #500358) (2.87 KB, patch)
2007-12-11 02:10 UTC, Jonathon Jongsma
none Details | Review
[PATCH] Redraw GtkHex widget when the HexDocument changes (Fix for bug #500358) (3.33 KB, patch)
2007-12-11 02:18 UTC, Jonathon Jongsma
committed Details | Review

Description Jonathon Jongsma 2007-11-29 04:55:02 UTC
I'm trying to use the GtkHex widget with data from memory.  When i call gtk_hex_set_data() to set some new data, I would expect the widget to update its display, however it doesn't seem to do so.  I have to actually minimize and unminimize (force an expose event, I suppose) in order for the new data to show up.  Also, after forcing the expose update, when you attempt to edit the hex data, the values don't always update until I update the entire the lower nibble (e.g. if I just change the upper nibble, it doesn't update its display).  I'll attach a test program which displays the issue for me.
Comment 1 Jonathon Jongsma 2007-11-29 04:55:42 UTC
Created attachment 99829 [details]
test program
Comment 2 Jonathon Jongsma 2007-11-29 04:57:33 UTC
I should note that the 'no update when only editing the upper nibble' problem doesn't seem to show up in ghex-the-application, only when I use the widget in my application.
Comment 3 Jonathon Jongsma 2007-12-01 04:32:41 UTC
Created attachment 99949 [details] [review]
[PATCH] Redraw GtkHex widget when the HexDocument changes


Connect to the HexDocument's document_changed signal and redraw the widget so
that the display gets updated when modifying the data with
hex_document_set_data().  Fix for bug #500358
---
 ChangeLog    |    7 +++++++
 src/gtkhex.c |   19 ++++++++++++++++++-
 src/gtkhex.h |    2 +-
 3 files changed, 26 insertions(+), 2 deletions(-)
Comment 4 Jonathon Jongsma 2007-12-01 15:59:27 UTC
OK, after investigating this a little bit more, I think I know why the GHex application doesn't exhibit this problem but my example program does.  I believe it is because the GHex application uses the function hex_document_add_view(), which creates a GtkHex widget and adds it to doc->views.  By default, the HexDocument's 'document_changed' signal handler emits the 'data_changed' signal for all views in doc->views, and this then causes the view to redraw itself.

However, if you create the GtkHex widget without using hex_document_add_view() (e.g. simply using gtk_hex_new(HexDocument*)), the GtkHex widget does not get added to doc->views.  Because of this, it never noticies that the underlying document has changed, because it relies on the HexDocument object to emit the 'data_changed' signal for the view.  

It seems that if the view simply always connected to the document's 'document_changed' signal in the constructor (as I've done in the patch above), we wouldn't even need the list of views in HexDocument...
Comment 5 Rodney Dawes 2007-12-09 21:35:40 UTC
Based on your last comment it sounds like we might also want to remove the list of views in HexDocument. Can you test that and rework the patch to do that as well? Thanks.
Comment 6 Jonathon Jongsma 2007-12-11 02:10:38 UTC
Created attachment 100729 [details] [review]
[PATCH] Redraw GtkHex widget when the HexDocument changes (Fix for bug #500358)


Connect to the HexDocument's document_changed signal and redraw the widget so
that the display gets updated when modifying the data with
hex_document_set_data().
Since the GtkHex view is connecting to the 'document_changed' signal, we no
longer have to rely on the HexDocument object to emit the 'data_changed' signal
for each view in the gh->views list.
---
 ChangeLog    |    7 +++++++
 src/gtkhex.c |   19 ++++++++++++++++++-
 src/gtkhex.h |    2 +-
 3 files changed, 26 insertions(+), 2 deletions(-)
Comment 7 Jonathon Jongsma 2007-12-11 02:16:59 UTC
Here's an updated patch.  It probably requires a little explanation -- In looking more closely at the code, it turns out that the list of views in HexDocument is still useful for the following situation:
  - There are multiple views of the same document open
  - the document has been changed
  - we only want to pop up a "close without saving?" dialog when they close the last view

So I left the list of views in, but they no longer have anything to do with the data_changed/document_changed signal.  That is now done exclusively by connecting to the signal in the GtkHex constructor.
Comment 8 Jonathon Jongsma 2007-12-11 02:18:11 UTC
Created attachment 100730 [details] [review]
[PATCH] Redraw GtkHex widget when the HexDocument changes (Fix for bug #500358)


Connect to the HexDocument's document_changed signal and redraw the widget so
that the display gets updated when modifying the data with
hex_document_set_data().
Since the GtkHex view is connecting to the 'document_changed' signal, we no
longer have to rely on the HexDocument object to emit the 'data_changed' signal
for each view in the gh->views list.
---
 ChangeLog          |    7 +++++++
 src/gtkhex.c       |   19 ++++++++++++++++++-
 src/gtkhex.h       |    2 +-
 src/hex-document.c |    8 --------
 4 files changed, 26 insertions(+), 10 deletions(-)
Comment 9 Jonathon Jongsma 2007-12-11 02:19:24 UTC
sorry for the noise, the first updated patch was incorrect -- marking obsolete
Comment 10 Jonathon Jongsma 2007-12-19 14:55:06 UTC
just fyi, I'm waiting for these changes to get into ghex svn so I can start committing the experimental memory editing stuff for nemiver.
Comment 11 Rodney Dawes 2007-12-19 15:18:59 UTC
Looks good. Please commit.
Comment 12 Jonathon Jongsma 2007-12-20 04:21:13 UTC
Thanks, committed in r1177