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 311740 - GimpDataFactory should reload only modified files
GimpDataFactory should reload only modified files
Status: RESOLVED FIXED
Product: GIMP
Classification: Other
Component: General
git master
Other All
: Normal enhancement
: 2.4
Assigned To: GIMP Bugs
GIMP Bugs
Depends on:
Blocks:
 
 
Reported: 2005-07-27 15:35 UTC by Shlomi Fish
Modified: 2005-10-31 11:29 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
A Patch to implement the suggestion. (11.50 KB, patch)
2005-07-27 15:37 UTC, Shlomi Fish
none Details | Review
A revised patch to implement the suggestion (14.77 KB, patch)
2005-08-17 17:20 UTC, Shlomi Fish
none Details | Review
cleaned up version of the above patch (15.33 KB, patch)
2005-10-06 13:43 UTC, Sven Neumann
none Details | Review
shorter version of the patch (15.44 KB, patch)
2005-10-14 14:54 UTC, Sven Neumann
needs-work Details | Review

Description Shlomi Fish 2005-07-27 15:35:09 UTC
Per suggestion of Sven Neumann on the IRC, GimpDataFactory should reload only 
the files that were modified. Namely, a GimpData sould keep track of the 
mtime, keep the files in a cache upon refreshing, and load only the files 
whose mtime is newer. 
 
A Patch would be attached to this bug to implement this suggestion.
Comment 1 Shlomi Fish 2005-07-27 15:37:47 UTC
Created attachment 49846 [details] [review]
A Patch to implement the suggestion.

This is a patch to implement the suggestion. It still duplicates a lot of code
and so should not be applied yet.
Comment 2 Shlomi Fish 2005-08-17 17:20:47 UTC
Created attachment 50863 [details] [review]
A revised patch to implement the suggestion

This is a revised patch that implements the suggestion. This time, the code of
the original patch was refactored so it will be more modular. It still has a
few rough spots like inconsistent function and variable naming (plus possibly
some style problems). However, as a general rule it is ready for prime time.
Comment 3 Sven Neumann 2005-10-06 13:43:44 UTC
Created attachment 53112 [details] [review]
cleaned up version of the above patch

Here's a revised version of that patch. It fixes a couple of coding style
issues.

Seems to work just fine but I haven't yet understood why the cache consists of
a hash table of lists of data items. Shouldn't a hash table of data items be
sufficient? But perhaps I just missed something here...
Comment 4 Shlomi Fish 2005-10-06 14:57:56 UTC
Sven: well, from what I understood there can be items with the same filenames, 
each in different directories in the data search path (say global data and 
user data). That's why each filename points to a list of such items. 
Comment 5 Sven Neumann 2005-10-07 10:26:06 UTC
Since the filenames are absolute filenames they are unique. The code would
become quite a bit simpler if it would make use of this fact.
Comment 6 Sven Neumann 2005-10-10 10:06:38 UTC
Hmm, there are indeed data objects sharing a same filename. There are a few
formats that provide multiple data objects from a single file. SVG gradients are
an example.
Comment 7 Sven Neumann 2005-10-14 14:54:40 UTC
Created attachment 53464 [details] [review]
shorter version of the patch

This version of the patch removes code duplication that the previous versions
had introduced. The function to actually load the data is now shared between
the load and the reload implementations. IMO this can go into CVS now, but I
haven't got around to give it some thorough testing.
Comment 8 Sven Neumann 2005-10-18 11:57:26 UTC
I can crash this code by modifying a data file on disk and reloading the data.
Before the crash the following critical assertion is triggered:
 g_object_unref: assertion `G_IS_OBJECT (object)' failed

  • #5 g_object_unref
    from /usr/lib/libgobject-2.0.so.0
  • #6 gimp_data_factory_refresh_cache_remove
    at gimpdatafactory.c line 238
  • #7 g_hash_table_size
    from /usr/lib/libglib-2.0.so.0
  • #8 gimp_data_factory_data_refresh
    at gimpdatafactory.c line 384

Comment 9 Sven Neumann 2005-10-19 20:39:37 UTC
Shlomi, can we expect you to have a look at this problem?
Comment 10 Shlomi Fish 2005-10-20 09:44:49 UTC
Sven: hi! Sorry for the late response. I'm quite busy right now in many other 
endeavours (including a day job), and so cannot guarantee I'll investigate 
this problem soon. You can try tackling it on your own, or otherwise wait for 
me to have some spare cycles to look at it. 
 
Thanks for all your work on the patch so far. 
 
Comment 11 Sven Neumann 2005-10-31 11:29:37 UTC
I think I fixed the problem by simplifying the code even further. The cache is
now kept around unmodified until the refresh operation is finished. Only at that
point it is cleared. Closing as FIXED.

2005-10-31  Sven Neumann  <sven@gimp.org>

	* app/core/gimpdata.[ch]
	* app/core/gimpdatafactory.c: applied a heavily modified version
	of the patch provided by Shlomi Fish in bug #311740. Introduces a
	cache to speed up reloading of data files.

	* app/actions/data-commands.c: set gimp busy while refreshing data
	factories.