pkulchenko / ZeroBraneStudio

Lightweight Lua-based IDE for Lua with code completion, syntax highlighting, live coding, remote debugger, and code analyzer; supports Lua 5.1, 5.2, 5.3, 5.4, LuaJIT and other Lua interpreters on Windows, macOS, and Linux

Home Page:http://studio.zerobrane.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Lua Error While running Chunk

fireymerlin opened this issue · comments

I was debugging a lua for windows program.
I also had an error while simply editing files, but I didn't copy that error down.

I recently re-installed Windows 11.
I installed ZBS 1.9 and then copied 2.1 over top of it.
Note: while typing this issue, the ZBS window just closed so I'm assuming it crashed.

For Lua for Windows, I install it using it's .exe file.
I then copy "winapi-1.0-lfw" to the proper sub-folders under lua\5.1
I then copy "serpent" to the proper sub-folders.

image

Just got this error. My lua program appears to continue running even with these errors.
image

@fireymerlin, thank you for the report. Can you show the content of the Help | About window?

Is this error reproducible? What are the steps that lead to this error shown and what's the content of the main editor windows (the one with editor tabs) when this happens?

image

The error was happening several times a day.
I have not been using ZBS the past 3 days. Just starting again today.
I'll let you know if it happens again.

The main editor window changes while I'm running the lus program (sometimes). The lua program will open lua files for edit if I request it to.
Normally, the editor window has the main lua program, another lua file that contains functions that the main lua program calls and sometimes lua data files from the world of warcraft game.
The top of the main lua program has the following statement to load the 2nd lua file
dofile(Program_dirname .. [[\SpecificFuntions.lua]])
I have the 2nd file open since I'm frequently "tweaking" it.
Any other lua files that are opened, are either lua code from a library or another file during a debug session or world of warcraft data files from the World of warcraft "WTF" folder.

Does your script also close the editor tabs? If it does, what method do you use to close them? It looks like in your case the notebook itself is deleted (so no editor tabs are left), which shouldn't happen, so that's why I am interested in both the steps that lead to this and how the editor window (with its tabs) looks when the error happens.

The script does not close any files open in ZBS. It opens the files by running the ZBS executable again. I do not programmatically interact with ZGS. I'm just using it to look at or edit the files.
Here is the lua code I'm using:
function runZeroBraneStudio(file)
local thisProgramName = 'runZeroBraneStudio'
Mywinapi.spawn(ZeroBraneStudio_filename .. ' "' .. file .. '"')
return
end
Where the following is declared earlier:
ZeroBraneStudio_filename = [[C:\Program Files (x86)\ZeroBraneStudio\zbstudio.exe]]

Today I got an error in ZBS while looking at a lua file that I had collapsed with F12 and was expanding different sections to look at.
Here is a screenshot of the file (this is a data file from a World of Warcraft addon.
image

Here is the error that popped up while I was viewing the file:
image

I usually have 3 files open in ZBS, but the script opens 1 additional file at a time depending on the options I select in my program. I may end up with 20 or 30 files open. For the previous error, I had less than 10 files open.

In doing some testing, I've found that some of the ZBS errors are occurring when I open a valid lua file but there may be special characters in it or it may be a very large file. I should add, in this case I'm not opening the lua file in ZBS to edit it, my script is reading the entire lua file into memory, my program changes values and then I use your "serpent.lua" module to write it back out as a text (*.lua) file.
Here is a screenshot showing the biggest file that my lua program could process:
image

The Questie.lua and Auctionator.lua files appear to have binary data in them and cause issue with my program so I no longer open those.

I've installed ZBS 1.90 to see if that helped. It did not.
I've restarted Windows. It is now to the point, that I'm getting an error while typing new code into ZBS.
image

Any suggestions?

Just now while trying to edit a lua script, I was getting the popup error message and noticed the following in the Output window
image

This is all utterly puzzling, as I can't figure out what may lead to this issue. It looks like some of the editor objects stop being editor objects and lose their methods. Can you try the following patch and let me know if it makes any difference?

diff --git a/src/editor/editor.lua b/src/editor/editor.lua
index 01151ff1..713a346c 100644
--- a/src/editor/editor.lua
+++ b/src/editor/editor.lua
@@ -480,6 +480,7 @@ end
 local delayed = {}
 
 function IndicateIfNeeded()
+  if not ide:IsValidCtrl(ide:GetEditorNotebook()) then return nil end
   local editor = ide:GetEditor()
   -- do the current one first
   if editor and delayed[editor] then
@@ -1290,6 +1291,7 @@ function CreateEditor(bare)
   editor.processedUpdateContent = 0
   editor:Connect(wxstc.wxEVT_STC_UPDATEUI,
     function (event)
+      if not ide:IsValidCtrl(editor) then return end
       -- some of UPDATEUI events may be triggered as the result of editor updates
       -- from subsequent events (like PAINTED, which happens in documentmap plugin).
       -- the reason for the `processed` check is that it is not possible
@@ -1334,6 +1336,7 @@ function CreateEditor(bare)
 
   editor:Connect(wx.wxEVT_IDLE,
     function (event)
+      if not ide:IsValidCtrl(editor) then editor.onidle = {} end
       while #editor.onidle > 0 do table.remove(editor.onidle, 1)(editor) end
     end)

If you still get any errors (with the patch), can you also include their screenshot? Thanks!

I had to ship my PC back to Dell for repairs. Dell replaced the CPU.
I would say you can close or delete this issue. I have not had any problems now that I have the PC back from Dell.

Sounds good; thank you for letting me know!