Commit Graph

461 Commits

Author SHA1 Message Date
Michael Natterer 901350ba20 app: use g_clear_pointer() in more places 2019-05-27 17:47:55 +02:00
Ell fa2e4dcce0 app: add gimp_parallel_run_async_independent_full()
... which is equivalent to gimp_parallel_run_async_independent(),
except that it takes an additional "priority" parameter, which
specifies the task's priority, with 0 being the default priority,
and lower values indicating higher priority.  Unlike
gimp_parallel_run_async_full(), the priority parameter doesn't
directly control the task's priority in a queue, but rather, we use
it to control the priority of the task's dedicated thread, on
supported platforms (previously, all independent async tasks would
run with low priority.)

Use low priority when loading fonts, which can take a long time, to
keep the existing behavior.
2019-03-06 00:01:59 -05:00
Ell 7c00cf498a app: use gimp_async_add_callback_for_object() in various places
Use gimp_async_add_callback_for_object(), added in the previous
commit, instead of gimp_async_add_callback(), in cases where the
destructor of the object owning the async doesn't wait for the
async to finish.  This avoids leaking such ongoing asyncs on
shutdown, during which gimp-parallel either finishes or aborts the
asyncs: if at this point an async has any registered callbacks, an
idle source is added for running the callbacks, extending the
lifetime of the async; however, since we're not getting back into
the main loop, the idle is never run, and the async (and any
associated resources) are never freed.
2018-11-30 04:14:10 -05:00
Ell 6bc0b3b8ad 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.
2018-10-01 05:24:45 -04:00
Ell a84b57e67e app: fix unhandled enumeration value warning in gimptextlayer.c 2018-09-18 16:23:19 -04:00
Ell 3b0040c043 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:39:56 -04:00
ONO Yoshio e98255efc1 Issue #2124 - The origin of vertical, right to left text does not...
... load correctly

Fixed incorrect initialization of private base_dir.
2018-08-31 08:40:16 +09:00
Michael Natterer 8226265b12 Issue #1954 - GIMP-2.99 color changes when converting between...
...linear and perceptual precision

Under certain circumstances (e.g. the image has no color profile),
GimpLayer's implementation of GimpDrawable::convert_type() didn't have
enough information to do the right color space conversion.

Intead of messing with stuff like "set profile in between doing a and b",
simply add a "src_profile" parameter to GimpDrawable::convert_type() so
the complete color space conversion information is available without
relying on obscure states that could change in the future.

Make sure all callers pass the right src_profile, particularly in
gimp_image_convert_precision(), which also needed fixing.
2018-08-05 22:28:56 +02:00
Jehan 5c56f8cb3a app: minor coding-style cleanup.
Adding spaces between function names and parenthese.

I would normally have just amended the contributed patches and pushed,
but gitlab is making our review process over-complicated with many
roundtrips with contributors, and review quality drops. Stating it here
for the records!
See commit 70945b8960 (where this cleaning
should have directly been done).
2018-08-02 12:59:53 +02:00
ONO Yoshio 70945b8960 Fixed that anchor position of text is shifted when text direction is changed.
anchor of LTR is top-left corner.
anchor of TTB-RTL is top-right cornner.
anchor of TTB-LTR is top-left cornner.
2018-08-02 10:29:54 +00:00
ONO Yoshio 587d9bbb03 MR !19: Add support for vertical text writing.
Squashed commit of the following:

commit ee1ff7d502658cfa1248a13a3f0348495db07eda
Author: ONO Yoshio <ohtsuka.yoshio@gmail.com>
Date:   Sun Jul 29 00:31:47 2018 +0900

    Fixed that gimp-text-dir-ttb-* icons are lacked in Symbolic.

commit d87d012d697628da28fe90199cc04b95b72ba8ef
Author: ONO Yoshio <ohtsuka.yoshio@gmail.com>
Date:   Sat Jul 28 16:23:10 2018 +0900

    Fix a typo.

commit cf0238bf7df56c384cdf3b7ec69557d14740f853
Author: ONO Yoshio <ohtsuka.yoshio@gmail.com>
Date:   Sat Jul 28 15:50:57 2018 +0900

    Fixed seg fault error.

commit b07f60d06f
Author: ONO Yoshio <ohtsuka.yoshio@gmail.com>
Date:   Fri Jul 27 17:15:34 2018 +0900

    Add support for vertical text writing.

    https://gitlab.gnome.org/GNOME/gimp/issues/641
2018-07-30 19:14:49 +02:00
Michael Natterer bab75b7365 Change a bazillion URLs to https://
Including all user-visible link and links called from code, like
the help pages.
2018-07-14 14:19:27 +02:00
Michael Natterer 5f700549e7 Change the license URL from http://www.gnu.org/licenses/ to https:// 2018-07-11 23:29:46 +02:00
Ell b4aece8a27 app: avoid CRITICAL when loading XCF with empty gimp-text-layer parasite 2018-07-05 22:47:45 -04:00
Ell b74e600c12 app: add gimp_parallel_run_async_{full,independent}()
Remove the "independent" parameter of gimp_parallel_run_async(),
and have the function always execute the passed callback in the
shared async thread-pool.

Add a new gimp_parallel_run_async_full() function, taking, in
addition to a callback and a data pointer:

  - A priority value, controlling the priority of the callback in
    the async thread-pool queue.  0 is the default priority (used
    by gimp_parallel_run_async()), negative values have higher
    priority, and positive values have lower priority.

  - A destructor function for the data pointer.  This function is
    called to free the user data in case the async operation is
    canceled before execution of the callback function begins, and
    the operation is dropped from the queue and aborted without
    executing the callback.  Note that if the callback *is*
    executed, the destructor is *not* used -- it's the callback's
    responsibility to free/recycle the user data.

Add a separate gimp_parallel_run_async_independent() function,
taking the same parameters, and executing the passed callback in
an independent thread, rather than the thread pool.  This function
doesn't take a priority value or a destructor (and there's no
corresponding "_full()" variant that does), since they're pointless
for independent threads.

Adapt the rest of the code to the changes.
2018-07-01 13:52:21 -04:00
Ell b5890e05b8 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.
2018-06-28 15:38:45 -04:00
Michael Natterer ca3ffec111 Issze #1711 - GIMP does not unref all GLocalFileEnumerator it uses
unref the enumerator when done. Spotted by Massimo.
2018-06-24 14:14:07 +02:00
Ell 7c7b6eb537 app: use default new-layer mode for layer groups and text layers
When creating a layer group, or a text layer, use the image's
default new-layer mode, instead of always using (non-legacy)
NORMAL.
2018-06-06 02:39:34 -04:00
Michael Natterer 73da7c9a54 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.
2018-06-04 13:49:07 +02:00
Michael Natterer 2ca408d146 app: add "new-func" and "get-standard-func" properties to GimpDataFactory
to make it behave better, and as preparation for further subclassing.
2018-06-04 12:18:13 +02:00
Michael Natterer d1b9f74c6f 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.
2018-06-03 23:16:29 +02:00
Michael Natterer 6b5fd27943 app: call the standard font "Standard" not "Sans-serif"
Sans-serif is also an actual font from the list and the standard font
is being used when there is really no font at all.
2018-06-03 23:13:55 +02:00
Michael Natterer 40b95227af app: make gimp_font_get_standard() return a GimpData
like all other GimpData sublasses.
2018-06-03 22:46:48 +02:00
Michael Natterer c563659ed8 app: move the GimpAsyncSet and the waiting code to GimpDataFactory
it's potentially useful for all data factories.
2018-06-03 22:28:00 +02:00
Michael Natterer 1b1739bb06 app: use gimp_data_factory_get_data_path() in GimpFontFactory
Also, make sure we freeze() and thaw() the font container correctly,
so that all places keep their fonts across a refresh.

The only thing to make this actually work seems to be a bug in the
list views, grid views work perfectly.
2018-06-03 20:44:28 +02:00
Michael Natterer e88fb8e9c7 app: remove all old font management code, switch to GimpFontFactory[View]
Biggest change in this commit is reordering stuff in GimpContext
because GimpFont is now a first class citizen.
2018-06-03 01:27:06 +02:00
Michael Natterer 0763ea2a69 app: add new GimpDataFactory subclass GimpFontFactory
which contains all the font loading and refreshing including all async
stuff and is a complete replacement for gimp-fonts.c and GimpFontList.
2018-06-03 01:25:25 +02:00
Michael Natterer 4d3c715990 app: derive GimpFont from GimpData 2018-06-03 00:45:06 +02:00
Ell 0e19f159f5 app: restore font list in async callback, not async-set notify handler
When font loading is finished, restore the font list in the
corresponding async completion callback, and not in the
"notify::empty" signal handler of the fonts async set

This solves a problem arising when gimp_fonts_wait() is called
*inside* a "notify::empty" signal handler, emitted when reloading
fonts (causing the "empty" property of the fonts async set to
switch from TRUE to FALSE):  When the wait is over, "empty" will
switch back from FALSE to TRUE, however, since the "notify" signal
is non-recursive, the corresponding handler will not be called,
gimp_fonts_wait() will return *before* the font list is restored,
and the caller will see an empty font list.  This can happen under
certain circumstances when reloading fonts while the text tool is
active.
2018-05-30 12:58:09 -04:00
Ell c27316093e app: code cleanup in previous commits 2018-05-30 02:22:34 -04:00
Ell f2134180de app, pdb: wait for fonts to load before dependent operations
Use gimp_fonts_wait(), added in the previous commit, to wait for
fonts to finish loading before operations that depend on font
availability.  In particular, this includes font- and text-related
PDB functions, and text-layer rendering.
2018-05-29 16:04:28 -04:00
Ell 0a5a4fed03 app: add gimp_fonts_wait()
... which waits for font-loading to complete, using gimp_wait() to
show a message while waiting.

Note that we don't currently allow the wait to be canceled, since
it may have unpredictable effects on plug-ins, but the interface is
such that the wait might not complete, so calling code should be
prepared for that.
2018-05-29 16:04:28 -04:00
Ell 1ac2b928d0 app: use GimpAsyncSet for keeping track of font loading
Replace the boolean fonts_loading member of Gimp with
fonts_async_set, which is a GimpAsyncSet object.  This allows us
to easily respond to the completion of font loading and reloading,
as will be done in the next commits.

Additionally, move the call to FcConfigSetCurrent(), used to
activate the loaded font configuration, from the async thread to
the main thread, just to be on the safe side, and avoid calling
FcInitReinitialize() in gimp_fonts_reset() if font loading is still
in progress, which is unsafe.
2018-05-29 16:04:28 -04:00
Ell ad8add6808 app: add "independent" parameter to gimp_parallel_run_async()
Add a boolean "independent" parameter to gimp_parallel_run_async().
When FALSE, the passed function is run in the shared async thread
pool; when TRUE, the passed function is run in an independent
thread.

Generally, async operations should run in the async pool, however,
it might be desirable to run long-standing operations, especially
ones that can't be canceled, in independent threads.  This avoids
stalling quicker operations, and shutdown.

Adapt the rest of the code for the change.  In particular,
initialize the font cache in an independent thread.
2018-05-27 13:17:24 -04:00
Jehan cfaa3103e7 app: output proper info message while fonts are loading.
To this effect, I add a variable to differentiate the "no-fonts on the
system" case from "fonts still loading".
2018-05-27 03:42:43 +02:00
Jehan 2484dec7d5 Issue #1211: Load fonts in background after startup.
Fonts should not be blocking startup as this provides a very bad
experience when people have a lot of fonts. This was experienced even
more on Windows where loading time are often excessively long.
We were already running font loading in a thread, yet were still
blocking startup (thread was only so that the loading status GUI could
get updated as a feedback). Now we will only start loading and proceed
directly to next steps.
While fonts are not loaded, the text tool will not be usable, yet all
other activities can be performed.
2018-05-27 02:13:33 +02:00
Ell 3e92e7a449 app: use gimp_parallel_run_async() when loading fonts
Replace the custom threading code with a call to
gimp_parallel_run_async().  This simplifies the code, while
maintaining the current (blocking) behavior.  In the future, we
might build upon this to actually load the fonts in the background.
2018-05-26 11:33:32 -04:00
Ell 08ff2ac8c8 app: use gimp_gegl_buffer_copy() all over the place
Replace all uses of gegl_buffer_copy() in app/ with
gimp_gegl_buffer_copy(), added in the previous commit.
2018-05-25 08:12:27 -04:00
Jehan 962b8496fc Bug 795899 - "Some fonts failed to load" error when missing fonts/...
... directory in the configuration folder.
This subfolder should have been created already. Just in case it is not
(for any reason), just recreate it rather than popping up an error.
2018-05-09 14:27:22 +02:00
Jehan 98a575370c app: add a check on not-NULL string before g_utf8_validate().
Still looking for possible crash case during gimp_font_list_load_names()
(cf. bug 795650). g_utf8_validate() segfaults if called with NULL.
Though looking at pango_font_description_to_string() implementation, it
doesn't look like it would ever return NULL. Yet it is worth
double-checking. We don't load font every second anyway.
2018-05-05 15:55:30 +02:00
Jehan d58f131b59 Bug 795650 - Gimp crashes on start in Windows.
Add more assertion checks (similar to commit d094ab7e56).

This is still not a fix per-se, but at least would make the code a bit
more robust. In particular FcObjectSetDestroy() could crash if somehow
FcObjectSetBuild() had returned a NULL pointer. And obviously
dereferencing a NULL fontset would crash as well.
Now if any of these happened, no fonts would be loaded. But at least
GIMP would not crash.
2018-05-05 15:26:26 +02:00
Jehan d094ab7e56 app: add some g_return_if_fail() in gimp_font_list_load_names().
Some crash happens inside this function (cf. bug 795650) on Windows.
Because of very inaccurate trace on this OS, it is hard to determine the
exact issue. Let's at least add some basic check on function parameters.
This won't fix any core issue, but may make things a bit more robust and
bugs easier to detect.
2018-05-01 03:41:37 +02:00
Jehan e796e3a50a app: popup error at startup when some fonts fail to load.
As proposed on IRC. This will allow people to debug their fonts (for
instance when there are permission issues or whatnot) by knowing the
list of problematic fonts in an error dialog at startup (and not only on
terminal).
2018-05-01 03:25:58 +02:00
Jehan 55d1ea5cf0 app: check that the font path is not NULL.
This is for Windows where we apparently need to call
g_win32_locale_filename_from_utf8() before feeding the path to
FcConfigAppFontAddFile().
Unfortunately as we discovered earlier (cf. commit ba06a0fe86), this
can sometimes return NULL. So we absolutely need to check for the path
not being NULL first.
2018-04-30 22:05:11 +02:00
Jehan 69f864d5f5 app: use a GFileEnumerator to loop through font files. 2018-04-30 21:58:19 +02:00
Jehan 3de1f33702 app: font loading output a GError.
This GError will either specify the font which failed to load (if
unique) or a vague message about fonts which fail to load.
Unfortunately right now, this message also goes to terminal because the
GUI is not ready yet.
2018-04-29 19:47:44 +02:00
Jehan 00dcd50a6c Bug 748553 - GIMP crash if a font does not have read permission.
Do not use FcConfigAppFontAddDir() because it seems to be half-loading
some fonts, even when they are not actually readable. On the other hand,
FcConfigAppFontAddFile() properly fails and does not leave the font list
in unstable state.
2018-04-29 17:34:13 +02:00
luz.paz 4a77ff2d3d Bug 795557 - Misc. typo fixes in source, comments and doxygen (pt3)
Found via `codespell` and grep.
2018-04-25 23:49:06 +02:00
Ell ce9ca03ed4 app: add gimp_drawable_{start,end,flush}_paint()
gimp_drawable_start/end_paint() are used to enter/exit paint mode
for a given drawable.  While the drawable is in paint mode,
gimp_drawable_get_buffer() returns a copy of the real drawable's
buffer, referred to as the paint buffer, so that modifications to
the returned buffer don't immediately affect the projection, and
calls to gimp_drawable_update() queue the updated region, instead
of emitting an "update" signal.

gimp_drawable_flush_paint() can be called while the drawable is in
paint mode, in order to copy the updated region of the paint buffer
back to the drawable's real buffer, and to emit "update" signals
for the queued region.

We use these functions in the next commit, to move painting to a
separate thread in the paint tools.
2018-04-08 09:42:47 -04:00
Ell 3b8e1ebecb app: use gimp_drawable_steal_buffer() in gimp_text_layer_from_layer()
When constructing a text layer from an existing layer in
gimp_text_layer_from_layer(), steal the old layer's buffer using
the new gimp_drawable_steal_buffer(), instead of using simple
pointer assignment, as the latter is generaly unsafe (even though
it should currently work).
2018-02-13 13:29:16 -05:00