Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

export gp7 throws exception #1025

Closed
1 task done
yibo7 opened this issue Nov 1, 2022 · 1 comment · Fixed by #1026
Closed
1 task done

export gp7 throws exception #1025

yibo7 opened this issue Nov 1, 2022 · 1 comment · Fixed by #1026
Assignees
Labels
area-core Related to some core parts of alphaTab platform-all Affects all platforms 🕷️ type-bug state-accepted This is a valid topic to work on.

Comments

@yibo7
Copy link

yibo7 commented Nov 1, 2022

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

export gp7 throws exception “System.NullReferenceException:“Object reference not set to an instance of an object.”

The calling code is as follows

var exporter = new AlphaTab.Exporter.Gp7Exporter();
            var settings = new Settings();
            settings.Importer.Encoding = "utf-8";
            AlphaTab.Core.EcmaScript.Uint8Array data = exporter.Export(score, settings);
            ArraySegment<byte> bytes = data.Data;
            string fileName = score.Title.Length > 0 ? score.Title + ".gp" : "Untitled.gp";
            var info = new FileInfo(sPath);
            string savePath = Path.Combine(info.DirectoryName, fileName);

            using (var fs = new System.IO.FileStream(savePath, System.IO.FileMode.Create))
            {
                fs.Write(bytes.Array, bytes.Offset, bytes.Count);
            }

Expected Behavior

Hope to export the gp file correctly

Steps To Reproduce

1.select the gtp file in test-gtp-files.zip

2.call Gp7Exporter of the *.Export(score, settings)

Link to jsFiddle, CodePen, Project

No response

Found in Version

1.2

Platform

.net (WinForms)

Environment

- **Windows 10**:
- **WinForm**:
- **.net 6**:

Anything else?

test-gtp-files.zip

image

@yibo7 yibo7 added the state-needs-triage Bug not triaged yet. label Nov 1, 2022
@Danielku15 Danielku15 added 🕷️ type-bug state-accepted This is a valid topic to work on. platform-all Affects all platforms area-core Related to some core parts of alphaTab and removed state-needs-triage Bug not triaged yet. labels Nov 1, 2022
@Danielku15
Copy link
Member

It's a bug related to the lyrics. They are declared as string[] | null (string[]? in .net syntax) but they are not initialized with empty strings as expected here:

alphaTab/src/model/Track.ts

Lines 103 to 105 in b1c4efa

if (!beat.lyrics) {
beat.lyrics = new Array<string>(lyrics.length);
}

Fix will be to either make the lyrics (string|null)[] | null (string?[]? in .net syntax) or fill them with empty strings there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-core Related to some core parts of alphaTab platform-all Affects all platforms 🕷️ type-bug state-accepted This is a valid topic to work on.
Projects
No open projects
AlphaTab 1.3
  
Awaiting triage
Development

Successfully merging a pull request may close this issue.

2 participants