Skip to content

Commit

Permalink
Добавлена дополнительная защита при работе с памятью
Browse files Browse the repository at this point in the history
  • Loading branch information
AJIOB committed Sep 4, 2017
1 parent 11c86e9 commit 9315e22
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions code/c++/cxx-api/AutoConnector.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include "AutoConnector.h"

AutoConnector::AutoConnector(std::function<void()> c, uint32_t f) : callback(c), frequency(f) {
AutoConnector::AutoConnector(std::function<void()> c, uint32_t f) : pConnectingThread(nullptr), callback(c),
frequency(f)
{
isRepeat.store(false);
}

Expand All @@ -9,7 +11,7 @@ AutoConnector::~AutoConnector() {
}

void AutoConnector::start() {
if (!isRepeat.load())
if (!isRepeat.load() && !pConnectingThread)
{
Data d;
d.callback = callback;
Expand All @@ -27,7 +29,7 @@ void AutoConnector::start() {
}

void AutoConnector::stop() {
if (isRepeat.load()) {
if (isRepeat.load() && pConnectingThread) {
isRepeat.store(false);
pConnectingThread->join();
delete pConnectingThread;
Expand Down
2 changes: 1 addition & 1 deletion code/c++/cxx-api/TrackPlatform_Manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
class TrackPlatform_Manager : public TrackPlatform_BasicManagement
{
static TrackPlatform_BasicConnector* createConnectorByMode(ConnectionModes mode, const CommunicationInfoStruct& info);
AutoConnector* pAutoConnector;
AutoConnector* pAutoConnector = nullptr;

public:
TrackPlatform_Manager(ConnectionModes mode, const CommunicationInfoStruct& info);
Expand Down

0 comments on commit 9315e22

Please sign in to comment.