Commit Graph

126 Commits

Author SHA1 Message Date
a66f88287c app: add missing includes for windows
(cherry picked from commit 46f706a403)
2020-04-13 11:57:38 +02:00
Ell
7058aa259b app: add gimp_data_factory_data_cancel()
Add a new GimpData::data_cancel() virtual function, and a
corresponding gimp_data_factory_data_cancel() function.  This
function should cancel any ongoing async operations related to the
factory (i.e., included in its async set), and wait for the
operations to finish.  Provide a default implementation that simply
cancels and waits on the factory's async set.

Use this function to cancel any ongoing operations during factory
destruction, and in gimp_data_factory_data_free().

Override this function in GimpFontFactory, for which we can't
really cancel font loading, and simply cancel and clear the
factory's async set without waiting for loading to finish, making
sure that nothing happens (and, in particular, that the factory
isn't being accessed, since it might be already dead) when loading
does finish.

(cherry picked from commit 6bc0b3b8ad)
2018-10-01 05:24:59 -04:00
Ell
937f5ea0f0 app: don't depend on GimpData sort order for identifying internal data
In gimp_data_factory_data_foreach(), don't rely on internal
GimpData objects being sorted first (while this is currently true
for all types of GimpData, they may override the sort order.)

(cherry picked from commit 50bab438ce)
2018-10-01 05:24:59 -04:00
Ell
31b369d09f app, libgimp*, modules: don't use g_type_class_add_private() ...
... and G_TYPE_INSTANCE_GET_PRIVATE()

g_type_class_add_private() and G_TYPE_INSTANCE_GET_PRIVATE() were
deprecated in GLib 2.58.  Instead, use
G_DEFINE_[ABSTRACT_]TYPE_WITH_PRIVATE(), and
G_ADD_PRIVATE[_DYNAMIC](), and the implictly-defined
foo_get_instance_private() functions, all of which are available in
the GLib versions we depend on.

This commit only covers types registered using one of the
G_DEFINE_FOO() macros (i.e., most types), but not types with a
custom registration function, of which we still have a few -- GLib
currently only provides a (non-deprecated) public API for adding a
private struct using the G_DEFINE_FOO() macros.

Note that this commit was 99% auto-generated (because I'm not
*that* crazy :), so if there are any style mismatches... we'll have
to live with them for now.
2018-09-18 14:41:35 -04:00
a88c0ffb93 Change the license URL from http://www.gnu.org/licenses/ to https:// 2018-07-11 23:47:19 +02:00
Ell
50db2b6655 app: a few async font loading fixes
In gimp_data_factory_finalize(), wait on the factory's async set
after canceling it, and before continuing destruction.  It's not
generally safe to just abandon an async op without waiting on it
-- this is a font-specific hack, due to the fact we can't actually
cancel font loading, and GimpFontFactory is prepared to handle
this.

Instead, in gimp_font_factory_finalize(), cancel and clear the
async set, so that GimpDataFactory doesn't actually wait for
loading to finish.

In gimp_font_factory_load_async_callback(), don't try to acess the
factory when the operation is canceled, since cancelation means the
factory is already dead.  On the other hand, when the opeation
isn't canceled, make sure to thaw the container even when font
loading failed, so that we always match the freeze at the begining
of the operation.

(cherry picked from commit b5890e05b8)
2018-06-28 15:38:55 -04:00
bd30f28b09 app: if --verbose, make GimpDataFactory print each loaded and saved data 2018-06-10 15:54:45 +02:00
226367d6cb app: add GimpDataLoaderFactory which loads data from an array of formats
specified by GimpDataLoaderEntry structs. Remove the same code from
GimpDataFactory and make it an abstract base class that only serves as
an interface for actual implementations. Also move around some stuff
in GimpDataFactory and remove virtual functions that were a bad idea
in the first place.

(cherry picked from commit 73da7c9a54)
2018-06-04 14:35:51 +02:00
e7ef28ef78 app: make gimp_data_factory_data_foreach() public
...this time without additional shit.

(cherry picked from commit 0b4677ec58)
2018-06-04 14:35:36 +02:00
aae538a4e5 app: add "new-func" and "get-standard-func" properties to GimpDataFactory
to make it behave better, and as preparation for further subclassing.

(cherry picked from commit 2ca408d146)
2018-06-04 14:35:18 +02:00
3220dc25f9 app: we always need to freeze/thaw around gimp_font_factory_data_init()
so pull it to the parent class. Also remove the "no_data" parameter
from the data_init() virtual function and handle it in
gimp_font_factory_data_init() itself.

(cherry picked from commit d1b9f74c6f)
2018-06-04 02:16:52 +02:00
5401066631 app: move the GimpAsyncSet and the waiting code to GimpDataFactory
it's potentially useful for all data factories.

(cherry picked from commit c563659ed8)
2018-06-03 22:50:20 +02:00
12f6a06070 app: add gimp_data_factory_get_data_path[_writable]()
which return GLists of GFiles. Use the new API in GimpDataFactory's
default implementations.

(cherry picked from commit 68cf2641f8)
2018-06-03 20:48:46 +02:00
0c04d3784b app: make GimpDataFactory properly derivable
Virtualize a lot of functions and move their code into the default
implementation. Also connect to changes of the "path" property and
reload data automatically when the path changes. Add "wait" method
which is by default empty but is to be implemented by fonts.

(cherry picked from commit 01e4104236)
2018-06-03 20:47:35 +02:00
d71ed88592 app: add buffering to reading data files
gimp_data_factory_load_data(): use a GBufferedInputStream so we don't
end up reading files byte-by-byte in the worst case.
2018-02-21 22:12:52 +01:00
0cb3e75f79 app: use a lot of g_clear_object() and g_clear_pointer()
More than 2000 lines of code less in app/, instead of

if (instance->member)
  {
    g_object_unref/g_free/g_whatever (instance->member);
    instance->member = NULL;
  }

we now simply use

g_clear_object/pointer (&instance->member);
2017-07-15 18:42:44 +02:00
84ee79c71d app: clean out many tabs under app/core/. 2016-11-25 05:51:03 +01:00
39909b6008 app: replace GimpList's internal GList with a GQueue
so we can easily iterate in reverse order, and access the last element
in O(1). Nothing makes use of this yet.
2016-05-01 15:22:44 +02:00
0ee649629e app: GimpDataFactory: get the data's mtime in the function where it's needed 2015-12-28 16:46:08 +01:00
16fa1b722d Bug 752582 - Error message when refreshing resources without...
...a writable resource directory

gimp_data_factory_data_save(): don't warn about a missing writable
directory if there is nothing to save.
2015-07-21 19:24:45 +02:00
9be16e00bc app: make sure name references to GimpData objects are serialized correctly
They were also serialized correctly before, but only because many
GimpData objects were (bogusly) always dirty after loading, which
caused them to always be written do disk on exit. This commit fixes
this problem and updates by-name references explicitly as things are
renamed, instead of relying on bugs.

Add gimp_data_factory_data_clean() which clears the dirty flags from
all a factory's objects. Call the new function on all factories at the
end of gimp_restore(), when all data has been loaded. This might be
total overkill, but ensures that everything is clean in the beginning.

Add new signal GimpContext::prop_name_changed() which is emitted when
any of the context's object properties (brush, gradient etc) is
renamed.

In GimpToolPreset, connect to the new signal and dirty the preset if a
relevant object propery was renamed, making sure the preset is saved
to disk later. Also optmize updates quite a bit by ignoring
notifications on tool option properties that are irrelevant to the
preset.

This might or might not address the issues discussed in bug #739487.
2015-02-26 22:31:58 +01:00
da26597467 app: add gimp_file_has_extension() and use it in GimpDataFactory 2014-08-02 23:29:00 +02:00
ab2afa0c1f app: don't check for a writable dir for each loaded GimpData
Instead, do the check once for each element of the data path, and pass
the result to the load functions.
2014-08-02 15:09:33 +02:00
2b1735f784 app: move gimp_file_compare() to gimp-utils.[ch]
It's a GCompareFunc to be used for finding GFiles in lists.
2014-08-02 15:07:26 +02:00
6821eb298c app: port GimpDataFactory file loading to GFileEnumerator
Also slightly change the semantics of gimp_data_set_folder_tags()
to be less complicated.
2014-08-01 20:30:45 +02:00
58c3b7661f app: port gimp_data_create_filename() to GFile
implies also porting gimp_data_factory_get_save_dir().
2014-07-26 16:37:30 +02:00
e618a2866c app: simplify handling of a GimpDataFactory's writable_path
Simply keep it around in GimpDataLoadContext during loading, instead
of g_object_set/getting it on the factory.
2014-07-26 14:21:39 +02:00
e6f4252d55 app: simplify GimpData load/save error reporting a lot
Add the filename and general "Foo failed" spam generically in GimpData
and GimpDataFactory, and make the individual loaders/savers much
simpler.
2014-07-04 18:46:02 +02:00
6f7e244d75 app: add GInputStream* parameter to GimpDataLoadFunc
and port all loaders to loading from an already open stream.
2014-07-04 03:31:03 +02:00
651c3d56ff app: more filename -> GFile 2014-07-01 15:56:39 +02:00
113617f526 app: change the GimpData loading API from filename to GFile 2014-07-01 02:30:22 +02:00
9696e297ac app: turn GimpData's "filename" string into a "file" GFile
One more step, but for now just causes more code in most places to get
to the path inside the GFile.
2014-07-01 01:19:35 +02:00
26738b9ff3 Bug 722487: Something in the attached .gimp-2.8 directory makes...
GIMP fail on start

Make gimp_tool_preset_load() robust against completely failed
deserializing.
2014-05-05 10:34:08 +02:00
8707701bee Bug 720163 - Typo fix for a console gimp-error message
s/configuation/configuration/
2013-12-10 14:48:08 +13:00
697572ccc0 app,libgimp*: fix includes to follow our include policy
- don't include <gdk-pixbuf/gdk-pixbuf.h> in headers in app/
- instead, include it in many .c files instead of <glib-object.h>,
  finally acknowledging the fact that app/ depends on gdk-pixbuf almost
  globally
- fix up includes as if libgimpbase depended in GIO, which it soon will
2013-10-15 01:58:39 +02:00
59c0c96921 app: add gimp_data_factory_get_data_type() 2012-10-07 00:17:01 +02:00
2a30a2bb74 Bug 684698 - Preferences-Folders: only 15 folder items accepted
Raise "max_paths" from 16 to 256 in all calls to gimp_path_parse().
2012-09-26 23:29:51 +02:00
867da8f293 app: add gimp_context_get_foreground,background_pixel()
which takes a Babl format to convert from/to.
Include <gegl.h> in a million places.
2012-05-02 17:50:41 +02:00
2303d292c3 app: initialize var before usage
to silence valgrind

==12105== Conditional jump or move depends on uninitialised value(s)
==12105==    at 0x6B069C: gimp_data_set_folder_tags (gimp/app/core/gimpdata.c:885)
==12105==    by 0x6B155E: gimp_data_factory_load_data (gimp/app/core/gimpdatafactory.c:922)
==12105==    by 0x64F34D0: gimp_datafiles_read_directories (gimp/libgimpbase/gimpdatafiles.c:155)
==12105==    by 0x6B1293: gimp_data_factory_data_load (gimp/app/core/gimpdatafactory.c:354)
==12105==    by 0x6B1E1C: gimp_data_factory_data_init (gimp/app/core/gimpdatafactory.c:239)
==12105==    by 0x6871D2: gimp_restore (gimp/app/core/gimp.c:952)
==12105==    by 0x47EABA: app_run (gimp/app/app.c:217)
==12105==    by 0x47E64D: main (gimp/app/main.c:440)
==12105==  Uninitialised value was created by a stack allocation
==12105==    at 0x6B1190: gimp_data_factory_data_load (gimp/app/core/gimpdatafactory.c:319)
2012-02-10 12:24:32 +01:00
0729c25bc0 app: set tags for all subdirectories a data file lives in
GimpData: add gimp_data_set_folder_tags() and remove the tag logic
from gimp_data_set_filename(). The function gets the toplevel data
directory passed so it knows where to stop assigning tags.

GimpDataFactory: when loading data, keep track of the currently
processed data hierachy's toplevel directory, and pass it to above new
function. Also make sure obsolete files don't get folder-tagged.
2012-02-09 10:02:49 +01:00
23ed56d75d app: gimp_data_factory_load_data(): fix handling of obsolete and writable
Make sure obsolete files are immutable, and propagate a folder's
"writable" state into its subfolders. Also clean up the function's
control flow to not fry the reader's brain.
2012-01-14 20:54:35 +01:00
caad58d203 app: add a GimpContext parameter to GimpDataLoadFunc 2010-04-11 13:12:41 +02:00
4fcf34699f app: flip context and name parameters in GimpDataNewFunc 2010-04-10 19:55:42 +02:00
430b0e5517 app: add a GimpContext parameter to all functions which create GimpData
and pass a context whereever needed. Fix up gimp_tool_preset_new()
to actually make a copy of the context's active tool's options.
2010-04-05 13:26:31 +02:00
345bbfe475 app: adjust wording and spelling in error messages 2009-12-26 20:46:19 +01:00
22767ca7b8 Seal GimpData completely and add the missing accessors 2009-10-31 18:48:38 +01:00
7abcfbf237 Add private struct to GimpData
And start sealing by moving "filename" there. Add
gimp_data_get_filename() and use it everywhere.
2009-10-31 15:24:57 +01:00
cfa76869d6 Bug 599797 - Crash on "Refresh dynamics" if ~/.gimp-2.7/dynamics folder is missing
(gimp_data_factory_refresh_cache_add): don't add data objects without
filename to the refresh cache. Regardless why they have no filename,
they can't be reloaded anyway (in this case it's newly created objects
that couldn't be saved because there is no folder to save them).
2009-10-30 22:58:19 +01:00
223cbeb6fb Fix gimp_data_factory_data_foreach()
Make the function do what is says also if the callback doesn't remove
the data from the factory, argh... also add "gboolean skip_internal"
parameter because doing that unconditionally feels equally broken.
2009-10-30 22:50:02 +01:00
a0e70231fb Rename cache utility function and reorder stuff to make more sense 2009-10-30 22:40:50 +01:00