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

View file

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

View file

@ -236,12 +236,12 @@ void GIFAnimComponent::setAnimation(const std::string& path)
mFrameRate = 1000.0 / static_cast<double>(mFrameTime); mFrameRate = 1000.0 / static_cast<double>(mFrameTime);
mFrameSize = mFileWidth * mFileHeight * 4; mFrameSize = mFileWidth * mFileHeight * 4;
mTargetPacing = static_cast<int>((1000.0 / mFrameRate) / static_cast<double>(mSpeedModifier)); mTargetPacing = static_cast<int>((1000.0 / mFrameRate) / static_cast<double>(mSpeedModifier));
int duration {mTargetPacing * mTotalFrames};
if (mDirection == "reverse") if (mDirection == "reverse")
mFrameNum = mTotalFrames - 1; mFrameNum = mTotalFrames - 1;
if (DEBUG_ANIMATION) { if (DEBUG_ANIMATION) {
const int duration {mTargetPacing * mTotalFrames};
LOG(LogDebug) << "GIFAnimComponent::setAnimation(): Width: " << mFileWidth; LOG(LogDebug) << "GIFAnimComponent::setAnimation(): Width: " << mFileWidth;
LOG(LogDebug) << "GIFAnimComponent::setAnimation(): Height: " << mFileHeight; LOG(LogDebug) << "GIFAnimComponent::setAnimation(): Height: " << mFileHeight;
LOG(LogDebug) << "GIFAnimComponent::setAnimation(): Total number of frames: " 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. // Some statistics for the file.
double duration {mAnimation->duration()};
mTotalFrames = mAnimation->totalFrame(); mTotalFrames = mAnimation->totalFrame();
mFrameRate = mAnimation->frameRate(); mFrameRate = mAnimation->frameRate();
mFrameSize = width * height * 4; mFrameSize = width * height * 4;
@ -204,6 +203,7 @@ void LottieAnimComponent::setAnimation(const std::string& path)
mFrameNum = mTotalFrames - 1; mFrameNum = mTotalFrames - 1;
if (DEBUG_ANIMATION) { if (DEBUG_ANIMATION) {
const double duration {mAnimation->duration()};
LOG(LogDebug) << "LottieAnimComponent::setAnimation(): Rasterized width: " << mSize.x; LOG(LogDebug) << "LottieAnimComponent::setAnimation(): Rasterized width: " << mSize.x;
LOG(LogDebug) << "LottieAnimComponent::setAnimation(): Rasterized height: " << mSize.y; LOG(LogDebug) << "LottieAnimComponent::setAnimation(): Rasterized height: " << mSize.y;
LOG(LogDebug) << "LottieAnimComponent::setAnimation(): Total number of frames: " LOG(LogDebug) << "LottieAnimComponent::setAnimation(): Total number of frames: "

View file

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

View file

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