Skip to content

Commit 22fd511

Browse files
committed
🐛 Fix crash that can happen while loading folder
1 parent f87d1f9 commit 22fd511

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

src/AnimationWallet.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,11 @@ void AnimationWallet::load_animations()
6868

6969
// Parsing Manifest.txt
7070
this->manifest = new Manifest(manifest_path);
71+
this->manifest_created = true;
7172

72-
if(!manifest->is_good) return;
73+
if(!this->manifest->is_good) return;
7374

74-
for(Manifest_animation man_anim: manifest->manifest_animations)
75+
for(Manifest_animation man_anim: this->manifest->manifest_animations)
7576
{
7677
for(Animation* anim: this->animations)
7778
{
@@ -96,7 +97,8 @@ AnimationWallet::~AnimationWallet()
9697
{
9798
for(Animation* anim: this->animations)
9899
delete(anim);
99-
delete(manifest);
100+
if(this->manifest_created)
101+
delete(this->manifest);
100102
}
101103

102104
void AnimationWallet::add_animation(std::string anim_folder)

src/AnimationWallet.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class AnimationWallet
1515
int animations_number = 0;
1616
std::vector<Animation*> animations;
1717
Manifest* manifest;
18+
bool manifest_created = false;
1819

1920
private:
2021
bool is_folder_correct = false;

src/main.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ int main(int argc, char* argv[])
3333
{
3434
const int version_major = 1;
3535
const int version_minor = 2;
36+
const int version_patch = 1;
3637
// Setup SDL
3738
// (Some versions of SDL before <2.0.10 appears to have performance/stalling issues on a minority of Windows systems,
3839
// depending on whether SDL_INIT_GAMECONTROLLER is enabled or disabled.. updating to the latest version of SDL is recommended!)
@@ -338,7 +339,7 @@ int main(int argc, char* argv[])
338339

339340
if(ImGui::BeginPopupModal("About", NULL, ImGuiWindowFlags_NoResize))
340341
{
341-
ImGui::Text("Flipper-Zero Animation Manager v%d.%d", version_major, version_minor);
342+
ImGui::Text("Flipper-Zero Animation Manager v%d.%d.%d", version_major, version_minor, version_patch);
342343
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 10.f);
343344
ImGui::Text("Made with <3 by Ooggle");
344345
ImGui::Text("https://github.com/Ooggle/FlipperAnimationManager"); // TODO: clickable link
@@ -376,7 +377,7 @@ int main(int argc, char* argv[])
376377
}
377378
ImGui::SameLine();
378379
if(animations_wallet->get_is_folder_correct())
379-
ImGui::TextColored(ImVec4(0.f, 1.f, 0.f, 1.00f), "Sucess, %d animations loaded", animations_wallet->animations_number);
380+
ImGui::TextColored(ImVec4(0.f, 1.f, 0.f, 1.00f), "Success, %d animations loaded", animations_wallet->animations_number);
380381
else
381382
{
382383
ImGui::TextColored(ImVec4(1.f, 0.f, 0.f, 1.00f), "Failed, folder not found");

0 commit comments

Comments
 (0)