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
http://studio.zerobrane.com/
Other
2.62k stars 518 forks source link

fix deprecated calls to wx/STC #994

Closed ildar closed 5 years ago

ildar commented 5 years ago

running ZBS with newer wxWindgets (namely 3.1.1) I get:

../src/stc/stc.cpp(5179): assert "unused==0" failed in StartStyling(): The second argument passed to StartStyling should be 0

A simple search shew StartStyling is used in two-arg form which is deprecated. (file src/editor/markup.lua)

pkulchenko commented 5 years ago

@ildar, correct, but unfortunately, there is no good way to interrogate Scintilla to check for that change. Switching to a one-argument version may not work either (although I'll have to test it). I wish there was a way to get the Scintilla version programmatically in wxlua, but as far as I remember, it wasn't available (GetLibraryVersionInfo() is comment out in wxlua and I couldn't figure out how to implement wxVersionInfo when I tried adding it).

ildar commented 5 years ago

Then maybe we can guess it during wxlua build either with parsing headers or giving the value manually as a last resort?

pkulchenko commented 5 years ago

This won't work, as the same ZBS code has to work with multiple wxlua versions, so the check has to be in the IDE code somehow. The only option I see is to check explicitly for the wxwidgets version. Can you try the following patch:

diff --git a/src/editor/markup.lua b/src/editor/markup.lua
index bedc4935..fe9413df 100644
--- a/src/editor/markup.lua
+++ b/src/editor/markup.lua
@@ -200,7 +200,7 @@ function MarkupStyle(editor, lines, linee)
             p = p + 1
             smark = smark - 1
           end
-          editor:StartStyling(p, ide.STYLEMASK)
+          editor:StartStyling(p, ide.wxver < "3.1.2" and ide.STYLEMASK or 0)
           editor:SetStyling(smark, markup[MD_MARK_MARK].st)
           editor:SetStyling(t-f+1-smark-emark, markup[mark].st or markup[MD_MARK_MARK].st)
           editor:SetStyling(emark, markup[MD_MARK_MARK].st)
@@ -214,7 +214,7 @@ function MarkupStyle(editor, lines, linee)
     -- has this line changed its wrapping because of invisible styling?
     if wrapped > 1 and editor:WrapCount(line) < wrapped then needfix = true end
   end
-  editor:StartStyling(es, ide.STYLEMASK)
+  editor:StartStyling(es, ide.wxver < "3.1.2" and ide.STYLEMASK or 0)

   -- if any wrapped lines have changed, then reset WrapMode to fix the drawing
   if needfix then
ildar commented 5 years ago

The edge version is 3.1.1 (or maybe even 3.1.0, need to check) But yes, 0 worked just fine. The idea with getting the version in wxlua implied storing it somewhere so that ZBS could get it from wxlua.

pkulchenko commented 5 years ago

yes, we can get wxwidgets version number, but there is no access to the Scintilla version number, which is what we'd need to check here.

wxwidgets master should be 3.1.2, no?

commit 33cb18f5e1cdb172cb280ca6bf1cd68b55f845a5 (tag: v3.1.2)
Author: Vadim Zeitlin <vadim@wxwidgets.org>
Date:   Sun Dec 9 16:21:40 2018 +0100
ildar commented 5 years ago

Wxlua can't be built with 3.1.2, the issue still open. They made big API changes and you still didn't catch up I'm currently on 3.1.1.

pkulchenko commented 5 years ago

Right, but the problem is that the current version of wxlua that ZBS is using is also 3.1.1 (wxwidgets was staying quite a bit of time on that version), so I can't use a check for 3.1.1 between two calls. I'll have to use the check for 3.1.2 with the expectation that wxlua gets integrated with the current wxwidgets master and then will work with the updated ZBS (that will include that check). I don't see another option unfortunately (and you'll probably need to update those calls manually in markup.lua if you want to run it with the latest wxwidgets 3.1.1).

fireymerlin commented 5 years ago

Should it be OK to use the Dec 25, 2018 version on GitHub for ZBS? I'm not used to using list servers. I hope this is the correct way to post.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/pkulchenko/ZeroBraneStudio/issues/994?email_source=notifications&email_token=AADL3MT6WCIGW7DRYN6GOU3PZEP3TA5CNFSM4HU2FEP2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODXDC7LA#issuecomment-499527596, or mute the thread https://github.com/notifications/unsubscribe-auth/AADL3MXZX75DHJ4XXONEP3TPZEP3TANCNFSM4HU2FEPQ .

pkulchenko commented 5 years ago

@fireymerlin, there are some changes in wxwidgets that are incompatible with wxlua version that the IDE is using, so wxlua will need to be updated first to support that. For example, see pkulchenko/wxlua/issues/21

pkulchenko commented 5 years ago

@ildar, I pushed changes to https://github.com/pkulchenko/wxlua/tree/wxwidgets312 that added GetLibraryVersionInfo for wxSTC, which will now report its version.

I still can't figure out where the SetStyle change happened to apply a proper check for it. Can you compile your 3.1.1 version using the latest wxlua and check what's returned when you run ide:GetEditor():GetLibraryVersionInfo():GetVersionString() in ZBS console?

ildar commented 5 years ago

Good 😀👍 Yet I can do that mid next week. Thanks!

pkulchenko commented 5 years ago

@ildar, I pushed a change that should fix the issue; let me know if you run into any issues with it.

ildar commented 5 years ago

just built it successfully, thanks a lot! everything looks fine except that https://github.com/pkulchenko/wxlua/issues/5 still persists.

pkulchenko commented 5 years ago

Good; thank you for the update. I'll comment on pkulchenko/wxlua#5 in that ticket.