Fixed a few issues reported by scan-build

This commit is contained in:
Leon Styhre 2023-11-02 12:38:19 +01:00
parent e6097b4fb0
commit 87a8d5a23a
6 changed files with 21 additions and 14 deletions

View file

@ -325,19 +325,19 @@ GuiMetaDataEd::GuiMetaDataEd(MetaDataList* md,
scraperParams.system->getSystemEnvData()->mLaunchCommands.size() > 1) {
row.makeAcceptInputHandler([this, title, scraperParams, ed, updateVal,
originalValue] {
GuiSettings* s {nullptr};
bool singleEntry {
const bool singleEntry {
scraperParams.system->getSystemEnvData()->mLaunchCommands.size() == 1};
if (!mInvalidEmulatorEntry && ed->getValue() == "" && singleEntry)
return;
GuiSettings* s {nullptr};
if (mInvalidEmulatorEntry && singleEntry)
s = new GuiSettings("CLEAR INVALID ENTRY");
else
s = new GuiSettings(title);
if (!mInvalidEmulatorEntry && ed->getValue() == "" && singleEntry)
return;
std::vector<std::pair<std::string, std::string>> launchCommands {
scraperParams.system->getSystemEnvData()->mLaunchCommands};

View file

@ -477,6 +477,8 @@ std::vector<HelpPrompt> ComponentGrid::getHelpPrompts()
const GridEntry* e {getCellAt(mCursor)};
if (e)
prompts = e->component->getHelpPrompts();
else
return prompts;
bool canScrollVert {false};

View file

@ -236,12 +236,12 @@ void GIFAnimComponent::setAnimation(const std::string& path)
mFrameRate = 1000.0 / static_cast<double>(mFrameTime);
mFrameSize = mFileWidth * mFileHeight * 4;
mTargetPacing = static_cast<int>((1000.0 / mFrameRate) / static_cast<double>(mSpeedModifier));
int duration {mTargetPacing * mTotalFrames};
if (mDirection == "reverse")
mFrameNum = mTotalFrames - 1;
if (DEBUG_ANIMATION) {
const int duration {mTargetPacing * mTotalFrames};
LOG(LogDebug) << "GIFAnimComponent::setAnimation(): Width: " << mFileWidth;
LOG(LogDebug) << "GIFAnimComponent::setAnimation(): Height: " << mFileHeight;
LOG(LogDebug) << "GIFAnimComponent::setAnimation(): Total number of frames: "

View file

@ -192,7 +192,6 @@ void LottieAnimComponent::setAnimation(const std::string& path)
}
// Some statistics for the file.
double duration {mAnimation->duration()};
mTotalFrames = mAnimation->totalFrame();
mFrameRate = mAnimation->frameRate();
mFrameSize = width * height * 4;
@ -204,6 +203,7 @@ void LottieAnimComponent::setAnimation(const std::string& path)
mFrameNum = mTotalFrames - 1;
if (DEBUG_ANIMATION) {
const double duration {mAnimation->duration()};
LOG(LogDebug) << "LottieAnimComponent::setAnimation(): Rasterized width: " << mSize.x;
LOG(LogDebug) << "LottieAnimComponent::setAnimation(): Rasterized height: " << mSize.y;
LOG(LogDebug) << "LottieAnimComponent::setAnimation(): Total number of frames: "

View file

@ -297,8 +297,6 @@ std::string Font::wrapText(const std::string& text,
continue;
}
charWidth = 0.0f;
byteCount = 0;
cursor = i;
// Needed to handle multi-byte Unicode characters.

View file

@ -198,7 +198,9 @@ namespace Utils
#else
if (!homePath.length()) {
const std::string& envHome {getenv("HOME")};
std::string envHome;
if (getenv("HOME") != nullptr)
envHome = getenv("HOME");
if (envHome.length())
homePath = getGenericPath(envHome);
}
@ -231,7 +233,10 @@ namespace Utils
return getGenericPath(Utils::String::wideStringToString(envHomeDrive) + "/" +
Utils::String::wideStringToString(envHomePath));
#else
return getenv("HOME");
std::string envHome;
if (getenv("HOME") != nullptr)
envHome = getenv("HOME");
return envHome;
#endif
return "";
}
@ -294,10 +299,12 @@ namespace Utils
return emulatorPath;
#else
const std::string& pathVariable {std::string {getenv("PATH")}};
std::string envPath;
if (getenv("PATH") != nullptr)
envPath = getenv("PATH");
const std::vector<std::string>& pathList {
Utils::String::delimitedStringToVector(pathVariable, ":")};
Utils::String::delimitedStringToVector(envPath, ":")};
std::string pathTest;