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 721249 - pdb.gimp_context_set_brush_size() dont't work
pdb.gimp_context_set_brush_size() dont't work
Status: RESOLVED FIXED
Product: GIMP
Classification: Other
Component: libgimp
2.8.10
Other All
: Normal normal
: 2.8
Assigned To: GIMP Bugs
GIMP Bugs
: 739919 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2013-12-30 21:49 UTC by Mihas'
Modified: 2014-11-10 23:23 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Illustration of unproper line (101.55 KB, image/png)
2013-12-30 21:49 UTC, Mihas'
  Details
Test plug-in to demonstrate the differences (1016 bytes, text/plain)
2014-02-05 03:14 UTC, Akkana Peck
  Details
linetest run in GIMP 2.6, using the circle 19 brush (12.82 KB, image/jpeg)
2014-02-05 03:16 UTC, Akkana Peck
  Details
linetest in git master (13.31 KB, image/jpeg)
2014-02-05 03:22 UTC, Akkana Peck
  Details
faulty unreferencing paint_options.patch (470 bytes, patch)
2014-08-31 09:12 UTC, Hartmut Kuhse
accepted-commit_now Details | Review

Description Mihas' 2013-12-30 21:49:57 UTC
Created attachment 265057 [details]
Illustration of unproper line

A Python-Fu function "pdb.gimp_context_set_brush_size()" do not sets the brush size. The size stays on default value.

How to reproduce:
1. Open GIMP, create a new image with white layer
2. Make sure foreground color is black.
3. Open python console (Filters/Python-Fu/Console)
4. Enter these commands:
image = gimp.image_list()[0]
drawable = image.layers[0]
ctrlpoints = [0,0,100,100]
pdb.gimp_context_set_brush_size(1.00)
pdb.gimp_paintbrush(drawable, 0, len(ctrlpoints), ctrlpoints, 0, 0)

And you'll see the line from picture from attachment instead of line with 1 pixel thickness. Similar result with pdb.gimp_pencil() and pdb.gimp_paintbrush_default().


OS Linux Mint 15 MATE x86_64
GIMP version is 2.8.10, the build from PPA (https://launchpad.net/~otto-kesselgulasch/+archive/gimp). However, that bug was in distribution's original GIMP 2.8.4 too.
Comment 1 Michael Schumacher 2013-12-30 23:01:01 UTC
Hm... the size changes, but the stroke uses the non-scaled sized.
Comment 2 Michael Natterer 2014-01-02 21:27:32 UTC
This is caused by commit 5d5430e110e1deb376e6bef09eeee7975dcc4fc6
which resets the brush size on each paint stroke. I have no clue
why this was done. Alexia?
Comment 3 Michael Natterer 2014-01-04 15:04:42 UTC
This does NOT fix this bug, it cleans up the "reset brush size"
code which is involved here.

commit b4477d8e01e4b03121a9b834d35b69d0d8374638
Author: Michael Natterer <mitch@gimp.org>
Date:   Sat Jan 4 15:45:25 2014 +0100

    app: add gimp_paint_options_set_default_brush_size()
    
    and use it globally instead of two different methods, one of which was
    forgotten to be ported to the new aspect ratio range where 0.0 means
    1:1. Add a FIXME comment in paint_tools.pdb where I think setting the
    default size is a bug, see #721249.
    
    (cherry picked from commit ef858453724f6d4ca105fc9daec038fdff358f30)

 app/core/gimpstrokeoptions.c     | 19 ++-----------------
 app/paint/gimppaintoptions.c     | 24 ++++++++++++++++++++++++
 app/paint/gimppaintoptions.h     |  3 +++
 app/pdb/context-cmds.c           |  8 ++------
 app/pdb/paint-tools-cmds.c       | 14 +++-----------
 app/tools/gimppaintoptions-gui.c | 10 +---------
 tools/pdbgen/pdb/context.pdb     | 10 +++-------
 tools/pdbgen/pdb/paint_tools.pdb | 14 +++-----------
 8 files changed, 41 insertions(+), 61 deletions(-)
Comment 4 Akkana Peck 2014-02-02 17:39:57 UTC
Probably related: this breaks plug-ins that call gimp-paintbrush or gimp-paintbrush-default expecting a wide stroke. Instead they get a narrow stroke the size of the base brush before scaling.
Comment 5 Michael Natterer 2014-02-03 22:09:52 UTC
Fixed in master and gimp-2-8, let's see what painting stuff breaks next...

commit 6cb5fcafb04c515f8773f81d6867efcedd95688e
Author: Michael Natterer <mitch@gimp.org>
Date:   Mon Feb 3 23:05:56 2014 +0100

    Bug 721249 - pdb.gimp_context_set_brush_size() dont't work
    
    Don't reset the brush size before each PDB paint stroke.
    
    (cherry picked from commit 9fe869236bbf178ac9699e0e789f78aa085e5ef6)

 app/pdb/paint-tools-cmds.c       | 4 ----
 tools/pdbgen/pdb/paint_tools.pdb | 4 ----
 2 files changed, 8 deletions(-)
Comment 6 Akkana Peck 2014-02-05 03:11:58 UTC
Nice, thanks!

There are still some differences for plug-in compatibility. The endpoints when using pdb.gimp_paintbrush to draw a line between two points seem to be drawn differently than they used to be (square instead of round, by default) and they extend farther out, past the endpoint specified. Also, gimp_edit_stroke still doesn't use the line width.

I'll attach a little python plug-in that illustrates the differences, and examples of its output in 2.6 vs. the just-fixed 2.9 (I'm assuming 2.8 will be the same). I thought I'd seen the old 2.6-style behavior in earlier 2.8 builds as well, but currently the oldest 2.8 I have handy is acting just like git master was before you fixed this bug (all thin lines, ignoring line width).

I could rewrite my plug-in (arrow designer, not linetest :-) to work with the new behavior, but I thought you'd want to know about the differences since some plug-ins might not get updated.
Comment 7 Akkana Peck 2014-02-05 03:14:27 UTC
Created attachment 268118 [details]
Test plug-in to demonstrate the differences

Here's a python plug-in to test a line drawn with gimp_paintbrush. Set the paintbrush size first, then open a new image and run Filters->Line test.
Comment 8 Akkana Peck 2014-02-05 03:16:46 UTC
Created attachment 268119 [details]
linetest run in GIMP 2.6, using the circle 19 brush

linetest run in GIMP 2.6, using the circle 19 brush.

And I forgot to mention that you should make a rect selection before running linetest -- it strokes the selection first so you can see how the line endpoints compare with the coordinates passed in.
Comment 9 Akkana Peck 2014-02-05 03:22:28 UTC
Created attachment 268120 [details]
linetest in git master

linetest in git master, using the pixel brush set to a size of 20.
Note the stroke ignores the line width, that the endpoints are square now, and extend outside the selection -- though I didn't use the measure tool, and it's hard to tell how they vary since the stroke widths aren't comparable. Restoring the old selection would be a better test, but gimp_image_select_item (which I use in 2.8+) doesn't work in 2.6 and I ran out of time before finding a 2.6-compatible way.
Comment 10 Michael Natterer 2014-02-05 08:46:15 UTC
OMG, stroking needs quite some love I'm afraid...
Comment 11 Michael Natterer 2014-02-06 22:41:01 UTC
This fixes stroking, master and gimp-2-8:

commit c15d7bcc8083533fa360c49eafcb48aeb119ce38
Author: Michael Natterer <mitch@gimp.org>
Date:   Thu Feb 6 23:20:39 2014 +0100

    Bug 721249 - pdb.gimp_context_set_brush_size() dont't work
    
    Port selection/path stroking to using the PDB-controllable
    paint options that live in GimpPDBContext.
    
    Change gimp_item_stroke()'s "use_default_values" boolean which was
    introduced at a time where we had no better way by a GimpPaintOptions
    parameter. If a non-NULL paint_options is passed (when called from the
    PDB), use it for stroking; if NULL is passed, use the actual paint
    tool options from the GUI (when called from the menus or the stroke
    dialog). In the PDB wrappers, get the right paint options object from
    the PDB context associated with the calling plug-in.
    
    (cherry picked from commit 4d6640ff79ff13ae6d031da477a21c85119b2f15)

 app/actions/select-commands.c  |  3 ++-
 app/actions/vectors-commands.c |  3 ++-
 app/core/gimpitem.c            |  8 ++++++--
 app/core/gimpitem.h            |  2 +-
 app/core/gimpstrokeoptions.c   | 14 ++++++--------
 app/core/gimpstrokeoptions.h   |  2 +-
 app/dialogs/stroke-dialog.c    |  4 ++--
 app/pdb/edit-cmds.c            | 29 +++++++++++++++++++++++------
 app/pdb/gimppdbcontext.c       |  4 +++-
 app/pdb/paths-cmds.c           | 15 ++++++++++++---
 tools/pdbgen/pdb/edit.pdb      | 28 ++++++++++++++++++++++------
 tools/pdbgen/pdb/paths.pdb     | 15 ++++++++++++---
 12 files changed, 92 insertions(+), 35 deletions(-)
Comment 12 Hartmut Kuhse 2014-08-31 09:12:25 UTC
Created attachment 284922 [details] [review]
faulty unreferencing paint_options.patch

In gimpstrokeoptions.c/gimp_stroke_options_prepare the paint_options are erroneously unref'd.
Gimp for windows crashes, gimp for linux reports a critical error.
Comment 13 Michael Natterer 2014-08-31 13:12:56 UTC
Comment on attachment 284922 [details] [review]
faulty unreferencing paint_options.patch

Indeed, please push to master and gimp-2-8.
Comment 14 Hartmut Kuhse 2014-08-31 13:36:53 UTC
fixed in master and 2.8

author	Hartmut Kuhse <hk_priv@gmx.de>
Date	2014-08-31 13:27:12 (GMT)
commit	ed42899041eb4948e492563bccdb5d44f07eb87f (patch)

app: erroneously dereferencing paint_optionsgimp-2-8
fixing commit 4d6640ff79ff13ae6d031da477a21c85119b2f15 
(cherry picked from commit 50463d8d5ab6e15c4d5345769bae795e7becdff7)

app/core/gimpstrokeoptions.c
Comment 15 Michael Schumacher 2014-11-10 23:23:10 UTC
*** Bug 739919 has been marked as a duplicate of this bug. ***