Skip to content

Commit

Permalink
Clear LdDecodeMetaData contents before reading a file. (#723)
Browse files Browse the repository at this point in the history
ld-analyse reuses the same object when you reload a file, which failed
because the existing metadata and fields were still present.
  • Loading branch information
atsampson authored May 16, 2022
1 parent 6a9a0a1 commit e564cf5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
20 changes: 16 additions & 4 deletions tools/library/tbc/lddecodemetadata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -355,22 +355,34 @@ void LdDecodeMetaData::Field::write(JsonWriter &writer) const

LdDecodeMetaData::LdDecodeMetaData()
{
// Set defaults
isFirstFieldFirst = false;
clear();
}

// Read all metadata from a JSON file
bool LdDecodeMetaData::read(QString fileName)
// Reset the metadata to the defaults
void LdDecodeMetaData::clear()
{
// Default to the standard still-frame field order (of first field first)
isFirstFieldFirst = true;

// Reset the parameters to their defaults
videoParameters = VideoParameters();
lineParameters = LineParameters();
pcmAudioParameters = PcmAudioParameters();

fields.clear();
}

// Read all metadata from a JSON file
bool LdDecodeMetaData::read(QString fileName)
{
std::ifstream jsonFile(fileName.toStdString());
if (jsonFile.fail()) {
qCritical("Opening JSON input file failed: JSON file cannot be opened/does not exist");
return false;
}

clear();

JsonReader reader(jsonFile);

try {
Expand Down
1 change: 1 addition & 0 deletions tools/library/tbc/lddecodemetadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ class LdDecodeMetaData
LdDecodeMetaData(const LdDecodeMetaData &) = delete;
LdDecodeMetaData& operator=(const LdDecodeMetaData &) = delete;

void clear();
bool read(QString fileName);
bool write(QString fileName) const;
void readFields(JsonReader &reader);
Expand Down

0 comments on commit e564cf5

Please sign in to comment.