[JW Lua] Changing independent key signatures crashes Finale
Jari Williamsson
jari.williamsson at mailbox.swipnet.se
Sat Jan 31 17:55:46 CET 2015
I know there are a couple of unhandled things related to cells and
independent keys, but it shouldn't crash. I remember recently changing
to a newer data version for independent cell data, but that should be in
the latest public JW Lua update.
I've attached both you issues to 2 separate bug reports.
The idea with cells and independent items is that there should always be
info available about what's currently used for the cell, even if the
info isn't independent.
Best regards,
Jari Williamsson
On 2015-01-29 18:27, Jan Angermüller wrote:
> 1.) If "Independent Element -> Key Signature" is NOT selected in the
> staff settings,
> the following code *may crash *Finale. It "may crash", as sometimes I
> have to run the script several times until it crashes, so there must be
> some undefined behaviour.
> Maybe this is by design and the developer has to make sure that it is a
> staff with an independent key signature before calling
> FCCell:GetKeySignature(). But it would be more safe if you inserted a
> quick check into the FCCell:GetKeySignature()-implementation.
> I would expect cell:GetKeySignature() to return nil on a non-independent
> key signature staff.
> That's better than crashing ;-)
> BTW, you have FCCell.HasIndependentTimeSig(). Maybe you could also add
> HasIndependentKeySig().
>
> This is the test code:
>
> --change key signature on first selected measure of first selected staff
> if not finenv.Region():IsEmpty() then
> local
> cell=finale.FCCell(finenv.Region().StartMeasure,finenv.Region().StartStaff)
> key=cell:GetKeySignature()
> if key ~= nil then
> print("Old alteration:", key.Alteration)
> key:SetMajorKey(5)
> print("New alteration:", key.Alteration)
> key:Save() --I don't know if this is necessary: same behaviour
> if I keep it in or take it out
> cell:Save() --this function call crashes Finale
> end
> end
>
> 2.) Now if "Independent Element -> Key Signature" IS selected in the
> staff settings and I also add a condition to check that key signatures
> are independent, the code above has the same behaviour: it still doesn't
> change any key signatures, but crashes Finale (if not after the first
> run, then after running it several times).
> This is the test code:
>
> --change key signature on first selected measure of first selected staff
> --with independent key signature check
> if not finenv.Region():IsEmpty() then
> local staff=finale.FCStaff()
> staff:Load(finenv.Region().StartStaff)
> if staff.IndependentKeySig then
> local
> cell=finale.FCCell(finenv.Region().StartMeasure,finenv.Region().StartStaff)
> key=cell:GetKeySignature()
> if key ~= nil then
> print("Old alteration:", key.Alteration)
> key:SetMajorKey(5)
> print("New alteration:", key.Alteration)
> key:Save() --I don't know if this is necessary: same
> behaviour if I keep it in or take it out
> cell:Save() --this function call crashes Finale
> end
> end
> end
>
> What works fine is changing the global key sig using
> FCMeasure:GetKeySignature(), i.e something like:
> local measure=finale.FCMeasure()
> measure:Load(1)
> local key=measure:GetKeySignature()
> key:SetMajorKey(5) --change key sig in measure 1
> measure:Save()
>
> Any ideas what the independent key sig thingy comes from ?
More information about the JWLua
mailing list