Skip to content

Commit

Permalink
Refactor to use smart pointers
Browse files Browse the repository at this point in the history
  • Loading branch information
momokotomoko committed May 27, 2023
1 parent 25579e2 commit baee0c4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 26 deletions.
30 changes: 7 additions & 23 deletions Sources/FFXIVOceanFishingTrackerPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,44 +22,28 @@

FFXIVOceanFishingTrackerPlugin::FFXIVOceanFishingTrackerPlugin()
{
mFFXIVOceanFishingHelper = new FFXIVOceanFishingHelper(
{
mFFXIVOceanFishingHelper = std::make_unique<FFXIVOceanFishingHelper>(
std::vector <std::string>({
"oceanFishingDatabase - Indigo Route.json",
"oceanFishingDatabase - Ruby Route.json"
}
})
);

// timer that is called on certain minutes of the hour
mTimer = new CallBackTimer();
mTimer = std::make_unique <CallBackTimer>();
//timer that is called every half a second to update UI
mSecondsTimer = new CallBackTimer();
mSecondsTimer = std::make_unique <CallBackTimer>();

startTimers();
}

FFXIVOceanFishingTrackerPlugin::~FFXIVOceanFishingTrackerPlugin()
{
if(mTimer != nullptr)
{
if(mTimer)
mTimer->stop();

delete mTimer;
mTimer = nullptr;
}

if (mSecondsTimer != nullptr)
{
if (mSecondsTimer)
mSecondsTimer->stop();

delete mSecondsTimer;
mSecondsTimer = nullptr;
}

if(mFFXIVOceanFishingHelper != nullptr)
{
delete mFFXIVOceanFishingHelper;
mFFXIVOceanFishingHelper = nullptr;
}
}

/**
Expand Down
6 changes: 3 additions & 3 deletions Sources/FFXIVOceanFishingTrackerPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ class FFXIVOceanFishingTrackerPlugin : public ESDBasePlugin

void updateImage(std::string pngfile, const std::string& inContext);

FFXIVOceanFishingHelper *mFFXIVOceanFishingHelper = nullptr;
CallBackTimer *mTimer = nullptr;
CallBackTimer* mSecondsTimer = nullptr;
std::unique_ptr<FFXIVOceanFishingHelper> mFFXIVOceanFishingHelper;
std::unique_ptr <CallBackTimer> mTimer;
std::unique_ptr <CallBackTimer> mSecondsTimer;

void startTimers();
};

0 comments on commit baee0c4

Please sign in to comment.