Skip to content

Commit 8253cfb

Browse files
committed
Replace internal global processor raw pointer with unique pointer
1 parent 0552d62 commit 8253cfb

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

ElunaEventMgr.cpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -112,20 +112,17 @@ void ElunaEventProcessor::RemoveEvent(LuaEvent* luaEvent)
112112
delete luaEvent;
113113
}
114114

115-
EventMgr::EventMgr(Eluna* _E) : globalProcessor(new ElunaEventProcessor(_E, NULL)), E(_E)
115+
EventMgr::EventMgr(Eluna* _E) : E(_E)
116116
{
117+
globalProcessor = std::make_unique<ElunaEventProcessor>(E, nullptr);
117118
}
118119

119120
EventMgr::~EventMgr()
120121
{
121-
{
122-
if (!processors.empty())
123-
for (ProcessorSet::const_iterator it = processors.begin(); it != processors.end(); ++it) // loop processors
124-
(*it)->RemoveEvents_internal();
125-
globalProcessor->RemoveEvents_internal();
126-
}
127-
delete globalProcessor;
128-
globalProcessor = NULL;
122+
if (!processors.empty())
123+
for (ProcessorSet::const_iterator it = processors.begin(); it != processors.end(); ++it) // loop processors
124+
(*it)->RemoveEvents_internal();
125+
globalProcessor->RemoveEvents_internal();
129126
}
130127

131128
void EventMgr::SetStates(LuaEventState state)

ElunaEventMgr.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ class EventMgr
9696
public:
9797
typedef std::unordered_set<ElunaEventProcessor*> ProcessorSet;
9898
ProcessorSet processors;
99-
ElunaEventProcessor* globalProcessor;
99+
std::unique_ptr<ElunaEventProcessor> globalProcessor;
100100
Eluna* E;
101101

102102
EventMgr(Eluna* _E);

0 commit comments

Comments
 (0)