otfried / ipe

The Ipe extensible drawing editor
http://ipe.otfried.org
145 stars 12 forks source link

Move to layer throws a Lua error #54

Closed Willem3141 closed 8 years ago

Willem3141 commented 8 years ago

I get a Lua error when trying to move objects to another layer.

To reproduce:

This throws the following error:

/usr/local/share/ipe/7.2.2/lua/actions.lua:1002: bad argument #2 to 'setLayerOf' (layer does not exist)
stack traceback:
    [C]: in function 'setLayerOf'
    /usr/local/share/ipe/7.2.2/lua/actions.lua:1002: in function 'redo'
    /usr/local/share/ipe/7.2.2/lua/model.lua:668: in function 'register'
    /usr/local/share/ipe/7.2.2/lua/actions.lua:1004: in function 'action_move_to_layer'
    /usr/local/share/ipe/7.2.2/lua/actions.lua:85: in function 'paction'
    /usr/local/share/ipe/7.2.2/lua/actions.lua:37: in function </usr/local/share/ipe/7.2.2/lua/actions.lua:37>
    [C]: in function 'xpcall'
    /usr/local/share/ipe/7.2.2/lua/actions.lua:37: in function </usr/local/share/ipe/7.2.2/lua/actions.lua:36>
    [C]: in function 'mainloop'
    /usr/local/share/ipe/7.2.2/lua/main.lua:466: in main chunk
    [C]: in function 'require'
    [string "require "main""]:1: in main chunk

A workaround for me is to right-click on the element and to set the layer there; this works normally.

I'm using Ipe 7.2.2 on Kubuntu (Linux).

otfried commented 8 years ago

I cannot reproduce this. How exactly are you adding the layer beta?

Willem3141 commented 8 years ago

I added the layer by the Layers > New Layer menu option. It does not matter how I add it though, even if I open an existing file with several layers I get this error.

If it helps, here is a screencast demonstrating the problem.

otfried commented 8 years ago

Can you set the environment variable IPEDEBUG (e.g. say "export IPEDEBUG=1") and check what output you get? I just tried it, it works and I get this output:

$ ipe
Debug messages enabled
size has changed to 937 x 487 (937 x 487)
action new_layer
action mode_rectangles
action movetolayer-beta
Willem3141 commented 8 years ago

Thanks for the suggestion. Unfortunately, there doesn't seem to be anything related to the error:

wsonke@nbwin1339:~$ export IPEDEBUG=1
wsonke@nbwin1339:~$ ipe
Debug messages enabled
size has changed to 887 x 467 (887 x 467)

I don't get any line starting with action. It seems that those are not emitted in the Qt version (in the source code, I can only find the corresponding ipeDebug statements in appui_cocoa.cpp and appui_win.cpp).

Edit: I copied the debug statement from appui_cocoa.cpp into appui_qt.cpp and recompiled. Now I get the following output:

wsonke@nbwin1339:~/Downloads/ipe-7.2.2/src$ ipe
Debug messages enabled
size has changed to 887 x 467 (887 x 467)
action mode_lines
action new_layer
action movetolayer-&beta

That & sign seems to be the culprit... maybe it is a focus marker?

otfried commented 8 years ago

Ah, very good. Which Qt version are you using?

Willem3141 commented 8 years ago

I'm using Qt 5.5.1.

otfried commented 8 years ago

Does the same problem occur with the other generated menus, e.g. Properties -> Text Style or Snap -> Grid size?

Willem3141 commented 8 years ago

You're right, indeed those menus exhibit similar symptoms, although none of them causes error messages like the layers menu:

(I didn't notice this before, as I normally use the popup menus to set those, and there is no problem with those.)

otfried commented 8 years ago

As a temporary solution, you could edit "actions.lua", and change the beginning of MODEL:paction from

function MODEL:paction(a)
  -- print("MODEL:paction(" .. a .. ")")

to

function MODEL:paction(a1)
  local a = a1:gsub("&", "")
  -- print("MODEL:paction(" .. a .. ")")

This is not a full solution, because now layer names containing an ampersand will not work anymore (not sure if that was ever supported), and similar for ampersands in property names (but there are none in the standard style sheets).

otfried commented 8 years ago

I hope this works as I can't check it - I'm still on Qt 5.2, where the problem doesn't occur. Another silent Qt behaviour change that bites us :-(

Willem3141 commented 8 years ago

This patch indeed fixes the issue with the layer menu for me. Thanks!