'Live Preview' toggle unsets current layer if nothing is selected

Bug #1086296 reported by su_v
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Inkscape
Invalid
Medium
Unassigned

Bug Description

If used without a current selection, the 'Live Preview' toggle in the extension dialogs unsets the current layer (making 'root' current drawing level instead). This may cause that a newly created object actually is created in 'root' (after having previewed a render effect), or that previewing e.g. a color effect with scope 'whole drawing' (nothing selected) will switch the current layer to 'root' without notifying the user.

Steps to reproduce:
1) draw an object
2) open 'Extensions > Color > Randomize…'
3) select object, toggle live preview on & off again
--> current layer is unchanged
4) unselect all, toggle live preview on & off again
--> current layer is switched to 'root'

or:
1) open new document
2) open 'Extensions > Render > Gear…'
3) toggle live preview on & off again
--> current layer is changed to 'root'
4) apply the affect
--> gear is created in 'root'

Since 'root' is outside the layer structure, this can cause issues later-on - objects may be created in 'root' without the user realizing it (some objects no longer hide when hiding layers), and fixing this is not obvious either (because 'root' is "excluded" or "hidden" from the layer UI options, unless one resorts to the XML Editor).

Reproduced with Inkscape 0.47, 0.48.3.1 and 0.48+devel r11927 on OS X 10.7.4.

Revision history for this message
su_v (suv-lp) wrote :

Attaching minimal test case (extension which reports current date, and the number of selected objects)

description: updated
Revision history for this message
su_v (suv-lp) wrote :
Revision history for this message
su_v (suv-lp) wrote :
su_v (suv-lp)
description: updated
Revision history for this message
jazzynico (jazzynico) wrote :

Confirmed on Debian testing, Inkscape trunk revision 11956.

Changed in inkscape:
importance: Undecided → Medium
status: New → Triaged
Revision history for this message
jazzynico (jazzynico) wrote :

Apparently affects external scripts only, not the internal ones (tested with some filters and the Grid extension).
Something wrong in inkex.py maybe...

Revision history for this message
jazzynico (jazzynico) wrote :

... or in the extension/implementation/script.cpp specific code.

Revision history for this message
jazzynico (jazzynico) wrote :

Can also be reproduced with:

1) open 'Extensions > Color > Randomize…'
2.a) select an object.
2.b) keep the selection empty.
3) apply the extension.
4) undo.

The selected layer is now root.

5) redo.

No change, we're still in root.

Revision history for this message
su_v (suv-lp) wrote :

The reason it doesn't happen when toggling live preview with a selection could be the call to 'reselect()' after the undo:
http://bazaar.launchpad.net/~inkscape.dev/inkscape/trunk/view/head:/src/extension/execution-env.cpp#L169

Could this be a limitation of the extension architecture that the current layer is initially not set after the document content is replaced with the output of the effect extension script, and the 'reselect()' causes the current layer to be restored to the layer of the first object in the selected items?

AFAIU changing the current layer is not recording in the undo history, and - if no selection existed - can't be restored by undo (or toggling live preview on/off again)…

Revision history for this message
su_v (suv-lp) wrote :

~suv wrote:
>JazzyNico wrote:
>> Apparently affects external scripts only, not the internal ones

> the current layer is initially not set after the document content
> is replaced with the output of the effect extension script

Which could also explain why internal extensions are not affected: AFAIU they don't have to completely replace the current document content with the output they generate, since they access the XML tree internally directly - hence the current layer level is not modified unless explicitly triggered by the extension?

Revision history for this message
Beluga (buovjaga) wrote :

I can't seem to repro, not with comment #7 either.

I do get this when enabling Live Preview:
  File "color_randomize.py", line 23
    self.OptionParser.add_option("-o", "--opacity_range",
                                                        ^
TabError: inconsistent use of tabs and spaces in indentation

Arch Linux 64-bit, KDE Plasma 5
Inkscape 0.92pre1 15073 (GTK3)

Revision history for this message
su_v (suv-lp) wrote :

Still reproduces with
- Inkscape 0.91 r13725 (OS X 10.7.5)
- lp:inkscape/0.92.x r15044 (OS X 10.7.5)
- lp:inkscape r15036 (OS X 10.7.5)
- lp:inkscape r15077 (Ubuntu 14.04.5 LTS)

--
@Beluga - you are unlikely to revisit this report, but anyway: Inkscape's python-based extensions are not yet compatible with Python 3, you need to make sure that Inkscape spawns the Python 2 interpreter (first 'python' binary in $PATH; else patch the source to force it to spawn 'python2' explicitly), and have Python 2, as well as the lxml and numpy modules for Python 2 installed. There's no point though to litter the fact about your local partially broken setup across the bug tracker: if you can't figure it out yourself, ask for help e.g. on irc or on one of the mailing lists, or - if you installed unstable Inkscape trunk via package maintained by your distro (archlinux: inkscape-bzr) - file a report there to properly manage python migration (python2 -> python3) for all packages they offer. IIRC last time I checked, the official arch linux packages for inkscape and inkscape-bzr did ok (patching the source to substitute 'python' with 'python2' for the interpreter, with (optional) dependencies on the python2 modules; though oddly no explicit runtime dependency on python2 itself (?)).

Revision history for this message
Jonathan Hofinger (jhofinger) wrote :

Not replicated in 0.92.4 and 1.1-dev (c990a67, 2020-04-09), Windows 10. Marking as Fix Released.

Please reopen on http://inkscape.org/report if the problem occurs again.

Closed by: https://gitlab.com/jhofinger

Changed in inkscape:
status: Triaged → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.