Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Bugfix for attempt to perform arithmetic on field 'wxMOD_RAW_CONTROL' (a nil value). #128

Closed
wants to merge 1 commit into from

2 participants

@samueldr

Fix for:
Lua: Error while running chunk
src/editor/editor.lua:664: attempt to perform arithmetic on field 'wxMOD_RAW_CONTROL' (a nil value)
stack traceback:
src/editor/editor.lua:664: in function
[C]: in function 'MainLoop'
src/main.lua:442: in main chunk
[C]: ?

which happens with 0.361 using Linux using wxwidgets 2.8. This behaviour could also be present using Windows though unverified.

@samueldr samueldr Bugfix for attempt to perform arithmetic on field 'wxMOD_RAW_CONTROL'…
… (a nil value).

Fix for:
	Lua: Error while running chunk
	src/editor/editor.lua:664: attempt to perform arithmetic on field 'wxMOD_RAW_CONTROL' (a nil value)
	stack traceback:
		src/editor/editor.lua:664: in function <src/editor/editor.lua:649>
		[C]: in function 'MainLoop'
		src/main.lua:442: in main chunk
		[C]: ?

which happens with 0.361 using Linux. This behaviour could also be present using Windows though unverified.
8c8a2d9
@pkulchenko
Owner

@samueldr, I can't reproduce this issue. wxMOD_RAW_CONTROL is defined in src/main.lua and is set to the value of wxMOD_CONTROL on Linux. I don't see any problem with 0.361 or 0.36 as both are defined for me; you can check in the Local console by typing wx.wxMOD_RAW_CONTROL (should return 2).

Can you provide details on how it fails for you?

@pkulchenko
Owner

@samueldr, have you been able to reproduce the issue? Do you have a list of steps for me to try?

@samueldr

Sorry for the late and long reply.

I did not actually test extensively the behaviour before sending this pull request, but it seems to originate from a difference between wxWidgets 2.9 and 2.8.

This will happen when using wxWidgets 2.8.

This happened to me since I used the CMake build to build a package for my distro, thus using the distributed version 2.8.12 currently.

Reproducing

To reproduce, use a distribution that uses the stable version of wxWidgets (2.8) and the matching wxLua. Otherwise, compile the needed packages to be on version 2.8

Start ZeroBrane with the system interpreter and not the one available in the bin directory of the git checkout. Also make sure to remove the bin directory as it is added in main.lua to the cpath.

Do a sanity check in the About dialog and check that it says Built with wxWidgets 2.8.12. The bundled libraries would give *Built with wxWidgets 2.9.5 *.

Press any key in the editor, it should traceback.

For the record, here is a fresh traceback (with current HEAD)

Lua: Error while running chunk
src/editor/editor.lua:664: attempt to perform arithmetic on field 'wxMOD_RAW_CONTROL' (a nil value)
stack traceback:
    src/editor/editor.lua:664: in function <src/editor/editor.lua:649>
    [C]: in function 'MainLoop'
    src/main.lua:442: in main chunk
    [C]: ?

Other notes

This quick pull requests actually fixes nothing and just patches. There is at least another issue with wxWidgets 2.8. This should be closed and proper discussion (or decision) should be done about compatibility with other wxLua/wxWidgets runtime than the one bundled in the repo.

This also affects the packageability of the software. Packages should not duplicate files and programs actually used by other packages; this would mean that ZeroBrane could not be cleanly packaged for most distributions at the time without making it compatible with wxWidgets 2.8.

For the record, Ubuntu 12.10 and the upcoming 13.04 also uses wxWidgets 2.8.

Remarks

The build with CMake actually does not copy the bin folder, needing a patch to the zbstudio shell script to make it use the system interpreter. It can be fixed though.

@pkulchenko
Owner

@samueldr; got it. You didn't specify originally that the issue was with wxwidgets 2.8.x. I agree about compatibility with wxwidgets 2.8.x, although I no longer test with that version as I bundle ZBS with wxwidgets 2.9.5.

Can you check the value of wx.wxMOD_CONTROL in the Locale Console while running 2.8.x? It seems like that value may be undefined, which is causing the issue you see. If that's the case, I have a simple fix for that, but it's going to be a bit different from what you've done. Thank you.

There is at least another issue with wxWidgets 2.8.

What issue is that?

This should be closed and proper discussion (or decision) should be done about compatibility with other wxLua/wxWidgets runtime than the one bundled in the repo. This also affects the packageability of the software. Packages should not duplicate files and programs actually used by other packages; this would mean that ZeroBrane could not be cleanly packaged for most distributions at the time without making it compatible with wxWidgets 2.8.

I agree, but I made a decision to continue with wxwidgets 2.9.x for the benefit of having better editor functionality, better Cocoa support on OSX and various bug fixes and at the cost of working through some of the current wxwidgets issues (you can see the details in #89).

I did made significant effort to preserve compatibility with 2.8 (you can check find several places with checks if you search for 2.9.5), but as I said, I'm not longer testing with that version, so can't guarantee that it's working with that version. I'll fix the issues if found though.

What do you get by sticking with wxwidgets 2.8? You still need to package and distribute wxlua (as I've been doing until v0.35), but this needs to be done in different ways for different platforms and it was much more complex than bundling the binaries I'm using now. BTW, wxlua is patched to make it work with live coding, so using the "standard" one will break that functionality.

@pkulchenko pkulchenko was assigned
@pkulchenko
Owner

Running ZBS on Windows using wxwidgets 2.8.12 doesn't have this issue.

It's possible that your wxlua is compiled without wxUSE_HOTKEY, which would cause wxMOD_CONTROL to be not defined (from wxlua/modules/wxbind/src/wxcore_bind.cpp):

#if wxUSE_HOTKEY
        { "wxMOD_CONTROL", wxMOD_CONTROL },
#endif // wxUSE_HOTKEY
@samueldr

At first, I did not even realize that ZeroBrane was bundled with a specific interpreter and libraries, as I was using a package configured by another user from the Arch User Repository. I tried updating the build script to use ZeroBrane Studio 0.361 instead of 0.35 and it's then that I had those issues.

There is at least another issue with wxWidgets 2.8.

What issue is that?

Here's the fix; CopyAllowLine does not exist in wxWidgets 2.8.
samueldr/ZeroBraneStudio@8a200e3

I made a decision to continue with wxwidgets 2.9.x

Seeing that you actually intended to support wxWidgets 2.9 I'm confident that I can close this pull request.

What do you get by sticking with wxwidgets 2.8?

Wouldn't know. This is just how it happened, I built the package, did not work. Fixed it (wrongly I think) made a quick pull request without thinking and testing other things.

What I said about packaging is just about distribution-dependent packaging (if it made sense). A software distributor could as well make a package with everything it needs built-in; it's just not a good citizen packaging wise, but if it's what it takes to work, then it's the thing to do.

I will look instead into updating the package to actually not depend on the system's Lua, wxLua and wxWidgets.

@samueldr samueldr closed this
@pkulchenko
Owner

@samueldr, I'll fix CopyAllowLine as you suggested and will fix wx.wxMOD_CONTROL. Have you had a chance to check if it was indeed nil in the Local Console (I just want to make sure I apply the correct fix)?

This should make the current code more 2.8.x friendly. I agree that some people may want to stick with system libraries, although I tried to make the process of using ZBS with different Linux distros as simple as possible.

@pkulchenko
Owner

And if I didn't mention this already, thank you for bringing this up (and providing a fix).

@samueldr

Completely forgot about that bit.

 =wx.wxMOD_CONTROL
 nil
@pkulchenko
Owner

@samueldr, could you please add a comment on the ArchLinux package page that the current version should work with 2.8? It also ships with binaries that are ArchLinux compatible (which wasn't the case before) and no additional package installation is needed. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 14, 2013
  1. @samueldr

    Bugfix for attempt to perform arithmetic on field 'wxMOD_RAW_CONTROL'…

    samueldr authored
    … (a nil value).
    
    Fix for:
    	Lua: Error while running chunk
    	src/editor/editor.lua:664: attempt to perform arithmetic on field 'wxMOD_RAW_CONTROL' (a nil value)
    	stack traceback:
    		src/editor/editor.lua:664: in function <src/editor/editor.lua:649>
    		[C]: in function 'MainLoop'
    		src/main.lua:442: in main chunk
    		[C]: ?
    
    which happens with 0.361 using Linux. This behaviour could also be present using Windows though unverified.
This page is out of date. Refresh to see the latest.
Showing with 2 additions and 2 deletions.
  1. +2 −2 src/editor/editor.lua
View
4 src/editor/editor.lua
@@ -660,8 +660,8 @@ function CreateEditor()
if event:ShiftDown() -- mark selection and scroll to caret
then editor:SetCurrentPos(pos) editor:EnsureCaretVisible()
else editor:GotoPos(pos) end
- elseif mod == wx.wxMOD_RAW_CONTROL and keycode == wx.WXK_PAGEUP
- or mod == (wx.wxMOD_RAW_CONTROL + wx.wxMOD_SHIFT) and keycode == wx.WXK_TAB then
+ elseif mod == wx.wxMOD_RAW_CONTROL and (keycode == wx.WXK_PAGEUP
+ or mod == (wx.wxMOD_RAW_CONTROL + wx.wxMOD_SHIFT) and keycode == wx.WXK_TAB) then
if notebook:GetSelection() == first
then notebook:SetSelection(last)
else notebook:AdvanceSelection(false) end
Something went wrong with that request. Please try again.