Skip to content

Commit

Permalink
Avoid printing in empty JSON block text export
Browse files Browse the repository at this point in the history
  • Loading branch information
Gumball2415 committed Dec 12, 2023
1 parent 2ce5ee2 commit 00a7eb8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Source/SoundGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2450,7 +2450,7 @@ void CSoundGen::UpdateAPU()
UpdateAPU();
l.unlock();
}
else TRACE("SoundGen: APU mutex lock failed");
else TRACE("SoundGen: APU mutex lock failed\n");
}
}

Expand Down
18 changes: 10 additions & 8 deletions Source/TextExporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1743,16 +1743,18 @@ const CString& CTextExport::ExportFile(LPCTSTR FileName, CFamiTrackerDoc *pDoc)
f.WriteString(_T("# JSON block\n"));
{
json j = pDoc->InterfaceToOptionalJSON();
std::string &jsondump = j.dump(4, ' ', true);
std::string &delimiter = std::string("\n");
std::string::size_type pos = 0, prev = 0;
while ((pos = jsondump.find(delimiter, prev)) != std::string::npos) {
s.Format(_T("%s %s\n"), CT[CT_JSON], ExportString(jsondump.substr(prev, pos - prev).c_str()));
if (!j.is_null()) {
std::string& jsondump = j.dump(4, ' ', true);
std::string& delimiter = std::string("\n");
std::string::size_type pos = 0, prev = 0;
while ((pos = jsondump.find(delimiter, prev)) != std::string::npos) {
s.Format(_T("%s %s\n"), CT[CT_JSON], ExportString(jsondump.substr(prev, pos - prev).c_str()));
f.WriteString(s);
prev = pos + delimiter.size();
}
s.Format(_T("%s %s\n"), CT[CT_JSON], ExportString(jsondump.substr(prev).c_str()));
f.WriteString(s);
prev = pos + delimiter.size();
}
s.Format(_T("%s %s\n"), CT[CT_JSON], ExportString(jsondump.substr(prev).c_str()));
f.WriteString(s);
}
f.WriteString(_T("\n"));

Expand Down

0 comments on commit 00a7eb8

Please # to comment.