cppcheck fixes

This commit is contained in:
Ingo Weyrich 2019-08-08 13:41:14 +02:00
parent d765c06cf4
commit 4bf4b818c0
9 changed files with 103 additions and 129 deletions

View File

@ -228,12 +228,12 @@ void ImProcFunctions::dehaze(Imagefloat *img)
array2D<float> dark(W, H);
int patchsize = max(int(5 / scale), 2);
int npatches = 0;
float ambient[3];
array2D<float> &t_tilde = dark;
float max_t = 0.f;
{
int npatches = 0;
array2D<float> R(W, H);
array2D<float> G(W, H);
array2D<float> B(W, H);

View File

@ -356,24 +356,19 @@ void ImProcFunctions::workingtrc(const Imagefloat* src, Imagefloat* dst, int cw,
{
const TMatrix wprof = ICCStore::getInstance()->workingSpaceMatrix(params->icm.workingProfile);
double dx = Color::D50x;
double dz = Color::D50z;
{
dx = dz = 1.0;
}
const float toxyz[3][3] = {
{
static_cast<float>(wprof[0][0] / (dx * (normalizeIn ? 65535.0 : 1.0))), //I have suppressed / Color::D50x
static_cast<float>(wprof[0][1] / (dx * (normalizeIn ? 65535.0 : 1.0))),
static_cast<float>(wprof[0][2] / (dx * (normalizeIn ? 65535.0 : 1.0)))
static_cast<float>(wprof[0][0] / ((normalizeIn ? 65535.0 : 1.0))), //I have suppressed / Color::D50x
static_cast<float>(wprof[0][1] / ((normalizeIn ? 65535.0 : 1.0))),
static_cast<float>(wprof[0][2] / ((normalizeIn ? 65535.0 : 1.0)))
}, {
static_cast<float>(wprof[1][0] / (normalizeIn ? 65535.0 : 1.0)),
static_cast<float>(wprof[1][1] / (normalizeIn ? 65535.0 : 1.0)),
static_cast<float>(wprof[1][2] / (normalizeIn ? 65535.0 : 1.0))
}, {
static_cast<float>(wprof[2][0] / (dz * (normalizeIn ? 65535.0 : 1.0))), //I have suppressed / Color::D50z
static_cast<float>(wprof[2][1] / (dz * (normalizeIn ? 65535.0 : 1.0))),
static_cast<float>(wprof[2][2] / (dz * (normalizeIn ? 65535.0 : 1.0)))
static_cast<float>(wprof[2][0] / ((normalizeIn ? 65535.0 : 1.0))), //I have suppressed / Color::D50z
static_cast<float>(wprof[2][1] / ((normalizeIn ? 65535.0 : 1.0))),
static_cast<float>(wprof[2][2] / ((normalizeIn ? 65535.0 : 1.0)))
}
};

View File

@ -234,8 +234,6 @@ rtengine::LCPProfile::LCPProfile(const Glib::ustring& fname) :
pCurCommon(nullptr),
aPersModel{}
{
const int BufferSize = 8192;
char buf[BufferSize];
XML_Parser parser = XML_ParserCreate(nullptr);
@ -250,6 +248,8 @@ rtengine::LCPProfile::LCPProfile(const Glib::ustring& fname) :
FILE* const pFile = g_fopen(fname.c_str (), "rb");
if (pFile) {
constexpr int BufferSize = 8192;
char buf[BufferSize];
bool done;
do {
@ -362,9 +362,8 @@ void rtengine::LCPProfile::calcParams(
const float focDist = aPersModel[pm]->focDist;
const float focDistLog = std::log(focDist) + euler;
double meanErr = 0.0;
if (aPersModel[pm]->hasModeData(mode)) {
double meanErr = 0.0;
double lowMeanErr = 0.0;
double highMeanErr = 0.0;

View File

@ -261,10 +261,10 @@ bool ProfileStore::parseDir (Glib::ustring& realPath, Glib::ustring& virtualPath
return fileFound;
}
int ProfileStore::findFolderId (const Glib::ustring &path)
int ProfileStore::findFolderId (const Glib::ustring &path) const
{
// initialization must have been done when calling this
for (std::vector<Glib::ustring>::iterator i = folders.begin(); i != folders.end(); ++i) {
for (std::vector<Glib::ustring>::const_iterator i = folders.begin(); i != folders.end(); ++i) {
if (*i == path) {
return i - folders.begin();
}
@ -454,7 +454,7 @@ const PartialProfile* ProfileStore::getDefaultPartialProfile (bool isRaw)
return pProf;
}
const Glib::ustring ProfileStore::getPathFromId (int folderId)
const Glib::ustring ProfileStore::getPathFromId (int folderId) const
{
// initialization must have been done when calling this
return folders.at (folderId);

View File

@ -185,7 +185,7 @@ public:
bool init (bool loadAll = true);
void parseProfiles ();
int findFolderId (const Glib::ustring &path);
int findFolderId (const Glib::ustring &path) const;
const ProfileStoreEntry* findEntryFromFullPath (Glib::ustring path);
const rtengine::procparams::PartialProfile* getProfile (Glib::ustring path);
const rtengine::procparams::PartialProfile* getProfile (const ProfileStoreEntry* entry);
@ -193,13 +193,13 @@ public:
void releaseFileList ();
const rtengine::procparams::ProcParams* getDefaultProcParams (bool isRaw);
const rtengine::procparams::PartialProfile* getDefaultPartialProfile (bool isRaw);
const Glib::ustring getPathFromId (int folderId);
const ProfileStoreEntry* getInternalDefaultPSE()
const Glib::ustring getPathFromId (int folderId) const;
const ProfileStoreEntry* getInternalDefaultPSE() const
{
return internalDefaultEntry;
}
const ProfileStoreEntry* getInternalDynamicPSE()
const ProfileStoreEntry* getInternalDynamicPSE() const
{
return internalDynamicEntry;
}

View File

@ -840,10 +840,10 @@ void FileBrowser::menuItemActivated (Gtk::MenuItem* m)
}
for (size_t i = 0; i < mselected.size(); i++) {
rtengine::procparams::ProcParams pp = mselected[i]->thumbnail->getProcParams();
pp.raw.dark_frame = fc.get_filename();
pp.raw.df_autoselect = false;
mselected[i]->thumbnail->setProcParams(pp, nullptr, FILEBROWSER, false);
rtengine::procparams::ProcParams lpp = mselected[i]->thumbnail->getProcParams();
lpp.raw.dark_frame = fc.get_filename();
lpp.raw.df_autoselect = false;
mselected[i]->thumbnail->setProcParams(lpp, nullptr, FILEBROWSER, false);
}
if (bppcl) {
@ -916,10 +916,10 @@ void FileBrowser::menuItemActivated (Gtk::MenuItem* m)
}
for (size_t i = 0; i < mselected.size(); i++) {
rtengine::procparams::ProcParams pp = mselected[i]->thumbnail->getProcParams();
pp.raw.ff_file = fc.get_filename();
pp.raw.ff_AutoSelect = false;
mselected[i]->thumbnail->setProcParams(pp, nullptr, FILEBROWSER, false);
rtengine::procparams::ProcParams lpp = mselected[i]->thumbnail->getProcParams();
lpp.raw.ff_file = fc.get_filename();
lpp.raw.ff_AutoSelect = false;
mselected[i]->thumbnail->setProcParams(lpp, nullptr, FILEBROWSER, false);
}
if (bppcl) {
@ -1079,17 +1079,17 @@ void FileBrowser::partPasteProfile ()
bppcl->beginBatchPParamsChange(mselected.size());
}
for (unsigned int i = 0; i < mselected.size(); i++) {
for (auto entry : mselected) {
// copying read only clipboard PartialProfile to a temporary one, initialized to the thumb's ProcParams
mselected[i]->thumbnail->createProcParamsForUpdate(false, false); // this can execute customprofilebuilder to generate param file
entry->thumbnail->createProcParamsForUpdate(false, false); // this can execute customprofilebuilder to generate param file
const rtengine::procparams::PartialProfile& cbPartProf = clipboard.getPartialProfile();
rtengine::procparams::PartialProfile pastedPartProf(&mselected[i]->thumbnail->getProcParams (), nullptr);
rtengine::procparams::PartialProfile pastedPartProf(&entry->thumbnail->getProcParams (), nullptr);
// pushing the selected values of the clipboard PartialProfile to the temporary PartialProfile
partialPasteDlg.applyPaste (pastedPartProf.pparams, pastedPartProf.pedited, cbPartProf.pparams, cbPartProf.pedited);
// applying the temporary PartialProfile to the thumb's ProcParams
mselected[i]->thumbnail->setProcParams (*pastedPartProf.pparams, pastedPartProf.pedited, FILEBROWSER);
entry->thumbnail->setProcParams (*pastedPartProf.pparams, pastedPartProf.pedited, FILEBROWSER);
pastedPartProf.deleteInstance();
}
@ -1502,8 +1502,8 @@ bool FileBrowser::checkFilter (ThumbBrowserEntryBase* entryb) const // true ->
std::transform(FileName.begin(), FileName.end(), FileName.begin(), ::toupper);
int iFilenameMatch = 0;
for (const auto& entry : filter.vFilterStrings) {
if (FileName.find(entry) != std::string::npos) {
for (const auto& filter : filter.vFilterStrings) {
if (FileName.find(filter) != std::string::npos) {
++iFilenameMatch;
break;
}

View File

@ -37,23 +37,22 @@ ProfileStoreComboBox::ProfileStoreComboBox ()
setPreferredWidth (50, 120);
}
Glib::ustring ProfileStoreComboBox::getCurrentLabel()
Glib::ustring ProfileStoreComboBox::getCurrentLabel() const
{
Glib::ustring currLabel;
Gtk::TreeModel::iterator currRow = get_active();
const Gtk::TreeModel::const_iterator currRow = get_active();
if (currRow) {
const ProfileStoreEntry *currEntry = (*currRow)[methodColumns.profileStoreEntry];
return currEntry->label;
}
return currLabel;
return {};
}
const ProfileStoreEntry* ProfileStoreComboBox::getSelectedEntry()
const ProfileStoreEntry* ProfileStoreComboBox::getSelectedEntry() const
{
Gtk::TreeModel::iterator currRow_ = get_active();
Gtk::TreeModel::Row currRow = *currRow_;
const Gtk::TreeModel::const_iterator currRow_ = get_active();
const Gtk::TreeModel::Row currRow = *currRow_;
if (currRow) {
return currRow[methodColumns.profileStoreEntry];
@ -145,18 +144,16 @@ void ProfileStoreComboBox::updateProfileList ()
cellRenderer->property_ellipsize_set() = true;
}
Gtk::TreeIter ProfileStoreComboBox::findRowFromEntry_ (Gtk::TreeModel::Children childs, const ProfileStoreEntry *pse)
Gtk::TreeIter ProfileStoreComboBox::findRowFromEntry_ (Gtk::TreeModel::Children childs, const ProfileStoreEntry *pse) const
{
Gtk::TreeModel::Row row;
Gtk::TreeIter rowInSubLevel;
for (Gtk::TreeModel::Children::iterator iter = childs.begin(); iter != childs.end(); ++iter) {
row = *iter;
for (const auto iter : childs) {
const Gtk::TreeModel::Row row = *iter;
// Hombre: is there a smarter way of knowing if this row has childs?
const ProfileStoreEntry *pse_ = row[methodColumns.profileStoreEntry];
if (pse_->type == PSET_FOLDER) {
rowInSubLevel = findRowFromEntry_ (iter->children(), pse);
const Gtk::TreeIter rowInSubLevel = findRowFromEntry_ (iter->children(), pse);
if (rowInSubLevel) {
// entry found
@ -171,30 +168,27 @@ Gtk::TreeIter ProfileStoreComboBox::findRowFromEntry_ (Gtk::TreeModel::Children
return childs.end();
}
Gtk::TreeIter ProfileStoreComboBox::findRowFromEntry (const ProfileStoreEntry *pse)
Gtk::TreeIter ProfileStoreComboBox::findRowFromEntry (const ProfileStoreEntry *pse) const
{
Gtk::TreeModel::Children childs = refTreeModel->children();
if (pse) {
Gtk::TreeIter row = findRowFromEntry_ (childs, pse);
return row;
return findRowFromEntry_ (childs, pse);
}
return childs.end();
}
Gtk::TreeIter ProfileStoreComboBox::findRowFromFullPath_ (Gtk::TreeModel::Children childs, int parentFolderId, Glib::ustring &name)
Gtk::TreeIter ProfileStoreComboBox::findRowFromFullPath_ (Gtk::TreeModel::Children childs, int parentFolderId, const Glib::ustring &name) const
{
Gtk::TreeModel::Row row;
Gtk::TreeIter rowInSubLevel;
for (Gtk::TreeModel::Children::iterator iter = childs.begin(); iter != childs.end(); ++iter) {
row = *iter;
for (const auto iter : childs) {
const Gtk::TreeModel::Row row = *iter;
// Hombre: is there a smarter way of knowing if this row has childs?
const ProfileStoreEntry *pse = row[methodColumns.profileStoreEntry];
if (pse->type == PSET_FOLDER) {
rowInSubLevel = findRowFromFullPath_ (iter->children(), parentFolderId, name);
const Gtk::TreeIter rowInSubLevel = findRowFromFullPath_ (iter->children(), parentFolderId, name);
if (rowInSubLevel) {
// entry found
@ -209,88 +203,77 @@ Gtk::TreeIter ProfileStoreComboBox::findRowFromFullPath_ (Gtk::TreeModel::Childr
return childs.end();
}
Gtk::TreeIter ProfileStoreComboBox::findRowFromFullPath (Glib::ustring path)
Gtk::TreeIter ProfileStoreComboBox::findRowFromFullPath (const Glib::ustring &path) const
{
Gtk::TreeIter row;
ProfileStore *profileStore = ProfileStore::getInstance();
if (path.empty()) {
return row;
return {};
}
const ProfileStore *profileStore = ProfileStore::getInstance();
if (path == DEFPROFILE_INTERNAL) {
row = findRowFromEntry (profileStore->getInternalDefaultPSE());
return row;
return findRowFromEntry (profileStore->getInternalDefaultPSE());
}
if (path == DEFPROFILE_DYNAMIC) {
row = findRowFromEntry (profileStore->getInternalDynamicPSE());
return row;
return findRowFromEntry (profileStore->getInternalDynamicPSE());
}
// removing the filename
Glib::ustring fName = Glib::path_get_basename (path);
const Glib::ustring fName = Glib::path_get_basename(path);
if (!fName.empty()) {
path = path.substr (0, path.length() - fName.length());
} else {
// path is malformed;
return row;
int parentFolderId = profileStore->findFolderId (Glib::path_get_dirname (path.substr (0, path.length() - fName.length())));
// 1. find the path in the folder list
if (parentFolderId != -1) {
return findRowFromFullPath_ (refTreeModel->children(), parentFolderId, fName);
}
}
path = Glib::path_get_dirname (path);
int parentFolderId = profileStore->findFolderId (path);
// 1. find the path in the folder list
if (parentFolderId != -1) {
row = findRowFromFullPath_ (refTreeModel->children(), parentFolderId, fName);
}
return row;
return {};
}
/** @brief Get the absolute full path of the active row entry.
* @return The absolute full path of the active row entry, or the "Internal" keyword,
* or an empty string if the ComboBox is in an invalid state
*/
Glib::ustring ProfileStoreComboBox::getFullPathFromActiveRow()
Glib::ustring ProfileStoreComboBox::getFullPathFromActiveRow() const
{
Glib::ustring path;
Gtk::TreeModel::iterator currRowI = get_active();
ProfileStore *profileStore = ProfileStore::getInstance();
const Gtk::TreeModel::const_iterator currRowI = get_active();
if (!currRowI) {
return path;
return {};
}
Gtk::TreeModel::Row currRow = *currRowI;
if (currRow) {
const ProfileStoreEntry *currEntry = currRow[methodColumns.profileStoreEntry];
if (!currEntry) {
return path;
return {};
}
const ProfileStore *profileStore = ProfileStore::getInstance();
if (currEntry == profileStore->getInternalDefaultPSE()) {
return Glib::ustring (DEFPROFILE_INTERNAL);
return DEFPROFILE_INTERNAL;
}
if (currEntry == profileStore->getInternalDynamicPSE()) {
return Glib::ustring (DEFPROFILE_DYNAMIC);
return DEFPROFILE_DYNAMIC;
}
path = Glib::build_filename (profileStore->getPathFromId (currEntry->parentFolderId), currEntry->label);
return Glib::build_filename (profileStore->getPathFromId (currEntry->parentFolderId), currEntry->label);
}
return path;
return {};
}
bool ProfileStoreComboBox::setActiveRowFromFullPath (Glib::ustring path)
bool ProfileStoreComboBox::setActiveRowFromFullPath (const Glib::ustring &path)
{
if (!path.empty()) {
Gtk::TreeIter row = findRowFromFullPath (path);
const Gtk::TreeIter row = findRowFromFullPath (path);
if (row) {
set_active (row);
@ -304,7 +287,7 @@ bool ProfileStoreComboBox::setActiveRowFromFullPath (Glib::ustring path)
bool ProfileStoreComboBox::setActiveRowFromEntry (const ProfileStoreEntry *pse)
{
if (pse) {
Gtk::TreeIter row = findRowFromEntry (pse);
const Gtk::TreeIter row = findRowFromEntry (pse);
if (row) {
set_active (row);
@ -321,16 +304,13 @@ bool ProfileStoreComboBox::setInternalEntry ()
}
/** @brief Get the row from the first level of the tree that match the provided name */
Gtk::TreeIter ProfileStoreComboBox::getRowFromLabel (Glib::ustring name)
Gtk::TreeIter ProfileStoreComboBox::getRowFromLabel (const Glib::ustring &name) const
{
Gtk::TreeIter row;
Gtk::TreeModel::Children childs = refTreeModel->children();
const Gtk::TreeModel::Children childs = refTreeModel->children();
if (!name.empty()) {
Gtk::TreeModel::Row currRow;
for (Gtk::TreeModel::Children::iterator iter = childs.begin(); iter != childs.end(); ++iter) {
currRow = *iter;
for (const auto iter : childs) {
const Gtk::TreeModel::Row currRow = *iter;
const ProfileStoreEntry *pse = currRow[methodColumns.profileStoreEntry];
if (pse->label == name) {

View File

@ -24,7 +24,6 @@
#include <glibmm.h>
#include "../rtengine/rtengine.h"
#include "../rtengine/noncopyable.h"
#include "../rtengine/profilestore.h"
#include "threadutils.h"
@ -35,7 +34,7 @@
/**
* @brief subclass of Gtk::Label with extra fields for Combobox and Menu, to link with a ProfileStoreEntry
*/
class ProfileStoreLabel : public Gtk::Label
class ProfileStoreLabel final : public Gtk::Label
{
public:
@ -44,7 +43,7 @@ public:
#ifndef NDEBUG
ProfileStoreLabel() : Gtk::Label ("*** error ***"), entry (nullptr) {}
#else
ProfileStoreLabel() : Gtk::Label (""), entry (NULL) {}
ProfileStoreLabel() : Gtk::Label (""), entry (nullptr) {}
#endif
/** @brief Create a new ProfileStoreLabel
@ -55,11 +54,11 @@ public:
ProfileStoreLabel (const ProfileStoreLabel &other);
};
class ProfileStoreComboBox : public MyComboBox
class ProfileStoreComboBox final : public MyComboBox
{
protected:
class MethodColumns : public Gtk::TreeModel::ColumnRecord
private:
class MethodColumns final : public Gtk::TreeModel::ColumnRecord
{
public:
Gtk::TreeModelColumn<Glib::ustring> label;
@ -74,21 +73,22 @@ protected:
Glib::RefPtr<Gtk::TreeStore> refTreeModel;
MethodColumns methodColumns;
void refreshProfileList_ (Gtk::TreeModel::Row *parentRow, int parentFolderId, bool initial, const std::vector<const ProfileStoreEntry*> *entryList);
Gtk::TreeIter findRowFromEntry_ (Gtk::TreeModel::Children childs, const ProfileStoreEntry *pse);
Gtk::TreeIter findRowFromFullPath_ (Gtk::TreeModel::Children childs, int parentFolderId, Glib::ustring &name);
Gtk::TreeIter findRowFromEntry_ (Gtk::TreeModel::Children childs, const ProfileStoreEntry *pse) const;
Gtk::TreeIter findRowFromFullPath_ (Gtk::TreeModel::Children childs, int parentFolderId, const Glib::ustring &name) const;
Gtk::TreeIter findRowFromEntry (const ProfileStoreEntry *pse) const;
Gtk::TreeIter findRowFromFullPath (const Glib::ustring &path) const;
public:
ProfileStoreComboBox();
void updateProfileList();
Glib::ustring getCurrentLabel();
const ProfileStoreEntry* getSelectedEntry();
Gtk::TreeIter findRowFromEntry (const ProfileStoreEntry *pse);
Gtk::TreeIter findRowFromFullPath (Glib::ustring path);
Glib::ustring getFullPathFromActiveRow ();
bool setActiveRowFromFullPath (Glib::ustring oldPath);
Glib::ustring getCurrentLabel() const;
const ProfileStoreEntry* getSelectedEntry() const;
Glib::ustring getFullPathFromActiveRow () const;
bool setActiveRowFromFullPath (const Glib::ustring &oldPath);
bool setActiveRowFromEntry (const ProfileStoreEntry *pse);
bool setInternalEntry ();
Gtk::TreeIter getRowFromLabel (Glib::ustring name);
Gtk::TreeIter getRowFromLabel (const Glib::ustring &name) const;
Gtk::TreeIter addRow (const ProfileStoreEntry *profileStoreEntry);
void deleteRow (const ProfileStoreEntry *profileStoreEntry);
};

View File

@ -225,21 +225,21 @@ void ThumbBrowserBase::selectSet (ThumbBrowserEntryBase* clicked)
static void scrollToEntry (double& h, double& v, int iw, int ih, ThumbBrowserEntryBase* entry)
{
const int hmin = entry->getX ();
const int hmax = hmin + entry->getEffectiveWidth () - iw;
const int vmin = entry->getY ();
const int vmax = vmin + entry->getEffectiveHeight () - ih;
const int hMin = entry->getX();
const int hMax = hMin + entry->getEffectiveWidth() - iw;
const int vMin = entry->getY();
const int vMax = vMin + entry->getEffectiveHeight() - ih;
if (hmin < 0) {
h += hmin;
} else if (hmax > 0) {
h += hmax;
if (hMin < 0) {
h += hMin;
} else if (hMax > 0) {
h += hMax;
}
if(vmin < 0) {
v += vmin;
} else if (vmax > 0) {
v += vmax;
if (vMin < 0) {
v += vMin;
} else if (vMax > 0) {
v += vMax;
}
}