Replace a dubious manual return-value-optimization by a standard named-return-value-optimization to simplify leak detection.
This commit is contained in:
@@ -2783,17 +2783,11 @@ TagDirectory* ExifManager::parseTIFF (FILE* f, bool skipIgnored)
|
|||||||
return parse (f, 0, skipIgnored);
|
return parse (f, 0, skipIgnored);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<Tag*> ExifManager::defTags;
|
std::vector<Tag*> ExifManager::getDefaultTIFFTags (TagDirectory* forthis)
|
||||||
|
|
||||||
// forthis: the byte order will be taken from directory "forthis"
|
|
||||||
const std::vector<Tag*>& ExifManager::getDefaultTIFFTags (TagDirectory* forthis)
|
|
||||||
{
|
{
|
||||||
|
std::vector<Tag*> defTags;
|
||||||
|
|
||||||
for (size_t i = 0; i < defTags.size(); i++) {
|
defTags.reserve (12);
|
||||||
delete defTags[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
defTags.clear ();
|
|
||||||
defTags.push_back (new Tag (forthis, lookupAttrib(ifdAttribs, "ImageWidth"), 0, LONG));
|
defTags.push_back (new Tag (forthis, lookupAttrib(ifdAttribs, "ImageWidth"), 0, LONG));
|
||||||
defTags.push_back (new Tag (forthis, lookupAttrib(ifdAttribs, "ImageHeight"), 0, LONG));
|
defTags.push_back (new Tag (forthis, lookupAttrib(ifdAttribs, "ImageHeight"), 0, LONG));
|
||||||
defTags.push_back (new Tag (forthis, lookupAttrib(ifdAttribs, "XResolution"), 300, RATIONAL));
|
defTags.push_back (new Tag (forthis, lookupAttrib(ifdAttribs, "XResolution"), 300, RATIONAL));
|
||||||
@@ -2843,14 +2837,16 @@ int ExifManager::createJPEGMarker (const TagDirectory* root, const rtengine::pro
|
|||||||
cl->applyChange (i->first, i->second);
|
cl->applyChange (i->first, i->second);
|
||||||
}
|
}
|
||||||
|
|
||||||
getDefaultTIFFTags (cl);
|
const std::vector<Tag*> defTags = getDefaultTIFFTags (cl);
|
||||||
|
|
||||||
defTags[0]->setInt (W, 0, LONG);
|
defTags[0]->setInt (W, 0, LONG);
|
||||||
defTags[1]->setInt (H, 0, LONG);
|
defTags[1]->setInt (H, 0, LONG);
|
||||||
defTags[8]->setInt (8, 0, SHORT);
|
defTags[8]->setInt (8, 0, SHORT);
|
||||||
|
|
||||||
for (int i = defTags.size() - 1; i >= 0; i--) {
|
for (int i = defTags.size() - 1; i >= 0; i--) {
|
||||||
cl->replaceTag (defTags[i]->clone (cl));
|
Tag* defTag = defTags[i];
|
||||||
|
cl->replaceTag (defTag->clone (cl));
|
||||||
|
delete defTag;
|
||||||
}
|
}
|
||||||
|
|
||||||
cl->sort ();
|
cl->sort ();
|
||||||
@@ -2928,7 +2924,7 @@ int ExifManager::createTIFFHeader (const TagDirectory* root, const rtengine::pro
|
|||||||
}
|
}
|
||||||
|
|
||||||
// append default properties
|
// append default properties
|
||||||
getDefaultTIFFTags (cl);
|
const std::vector<Tag*> defTags = getDefaultTIFFTags (cl);
|
||||||
|
|
||||||
defTags[0]->setInt (W, 0, LONG);
|
defTags[0]->setInt (W, 0, LONG);
|
||||||
defTags[1]->setInt (H, 0, LONG);
|
defTags[1]->setInt (H, 0, LONG);
|
||||||
@@ -2939,7 +2935,9 @@ int ExifManager::createTIFFHeader (const TagDirectory* root, const rtengine::pro
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (int i = defTags.size() - 1; i >= 0; i--) {
|
for (int i = defTags.size() - 1; i >= 0; i--) {
|
||||||
cl->replaceTag (defTags[i]->clone (cl));
|
Tag* defTag = defTags[i];
|
||||||
|
cl->replaceTag (defTag->clone (cl));
|
||||||
|
delete defTag;
|
||||||
}
|
}
|
||||||
|
|
||||||
// calculate strip offsets
|
// calculate strip offsets
|
||||||
|
@@ -306,8 +306,6 @@ public:
|
|||||||
class ExifManager
|
class ExifManager
|
||||||
{
|
{
|
||||||
|
|
||||||
static std::vector<Tag*> defTags;
|
|
||||||
|
|
||||||
static Tag* saveCIFFMNTag (FILE* f, TagDirectory* root, int len, const char* name);
|
static Tag* saveCIFFMNTag (FILE* f, TagDirectory* root, int len, const char* name);
|
||||||
public:
|
public:
|
||||||
static TagDirectory* parse (FILE*f, int base, bool skipIgnored = true);
|
static TagDirectory* parse (FILE*f, int base, bool skipIgnored = true);
|
||||||
@@ -316,7 +314,10 @@ public:
|
|||||||
static TagDirectory* parseCIFF (FILE* f, int base, int length);
|
static TagDirectory* parseCIFF (FILE* f, int base, int length);
|
||||||
static void parseCIFF (FILE* f, int base, int length, TagDirectory* root);
|
static void parseCIFF (FILE* f, int base, int length, TagDirectory* root);
|
||||||
|
|
||||||
static const std::vector<Tag*>& getDefaultTIFFTags (TagDirectory* forthis);
|
/// @brief Get default tag for TIFF
|
||||||
|
/// @param forthis The byte order will be taken from the given directory.
|
||||||
|
/// @return The ownership of the return tags is passed to the caller.
|
||||||
|
static std::vector<Tag*> getDefaultTIFFTags (TagDirectory* forthis);
|
||||||
static int createJPEGMarker (const TagDirectory* root, const rtengine::procparams::ExifPairs& changeList, int W, int H, unsigned char* buffer);
|
static int createJPEGMarker (const TagDirectory* root, const rtengine::procparams::ExifPairs& changeList, int W, int H, unsigned char* buffer);
|
||||||
static int createTIFFHeader (const TagDirectory* root, const rtengine::procparams::ExifPairs& changeList, int W, int H, int bps, const char* profiledata, int profilelen, const char* iptcdata, int iptclen, unsigned char* buffer);
|
static int createTIFFHeader (const TagDirectory* root, const rtengine::procparams::ExifPairs& changeList, int W, int H, int bps, const char* profiledata, int profilelen, const char* iptcdata, int iptclen, unsigned char* buffer);
|
||||||
};
|
};
|
||||||
|
@@ -156,13 +156,16 @@ void ExifPanel::setImageData (const ImageMetaData* id)
|
|||||||
idata = id;
|
idata = id;
|
||||||
exifTreeModel->clear ();
|
exifTreeModel->clear ();
|
||||||
|
|
||||||
const std::vector<Tag*>& defTags = ExifManager::getDefaultTIFFTags (NULL);
|
const std::vector<Tag*> defTags = ExifManager::getDefaultTIFFTags (NULL);
|
||||||
|
|
||||||
for (size_t i = 0; i < defTags.size(); i++)
|
for (size_t i = 0; i < defTags.size(); i++) {
|
||||||
if (defTags[i]->nameToString() == "ImageWidth" || defTags[i]->nameToString() == "ImageHeight" || defTags[i]->nameToString() == "BitsPerSample") {
|
Tag* defTag = defTags[i];
|
||||||
addTag (exifTreeModel->children(), defTags[i]->nameToString(), "?", AC_SYSTEM, false);
|
if (defTag->nameToString() == "ImageWidth" || defTag->nameToString() == "ImageHeight" || defTag->nameToString() == "BitsPerSample") {
|
||||||
|
addTag (exifTreeModel->children(), defTag->nameToString(), "?", AC_SYSTEM, false);
|
||||||
} else {
|
} else {
|
||||||
addTag (exifTreeModel->children(), defTags[i]->nameToString(), defTags[i]->valueToString(), AC_SYSTEM, false);
|
addTag (exifTreeModel->children(), defTag->nameToString(), defTag->valueToString(), AC_SYSTEM, false);
|
||||||
|
}
|
||||||
|
delete defTag;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (id && id->getExifData ()) {
|
if (id && id->getExifData ()) {
|
||||||
|
Reference in New Issue
Block a user