Commits

Ryan Kistner  committed 5478d11

Need to call clear() on the maps to properly destruct them.

  • Participants
  • Parent commits b050434

Comments (0)

Files changed (4)

File steam_api/apitest/main.cpp

 	qq.m_SteamCallResultLobbyMatchList.Set(hSteamAPICall, &qq, &CLobbyBrowser::OnLobbyMatchListCallback );
 
 
-	for(int i = 0; i < 10; i++)
+	while(true)
 	{
 		SteamAPI_RunCallbacks();
 		Sleep(100);

File steam_api/callbacks.cpp

 	ResolveExports();
 }
 
+void CallbackManager::Cleanup()
+{
+	callbacks.clear();
+	apicalls.clear();
+}
+
 void CallbackManager::SetCallbackProvider(HMODULE module)
 {
 	provider.Set(module);
 
 void CallbackManager::UnRegisterCallback(CCallbackBase *callback)
 {
-	int iCallback = callback->GetICallback();
-
-	std::pair<CallbacksMap::iterator, CallbacksMap::iterator> range = callbacks.equal_range( iCallback );
+	std::pair<CallbacksMap::iterator, CallbacksMap::iterator> range = callbacks.equal_range( callback->GetICallback() );
 
 	CallbacksMap::const_iterator iter = range.first;
 	while(iter != range.second)

File steam_api/callbacks.h

 class CallbackManager
 {
 public:
+	~CallbackManager() { Cleanup(); };
+
 	void SetCallbackProvider(HMODULE module);
 	void RunCallbacks(HSteamPipe pipe, bool bGameServer);
 
 	void RegisterAPICallResult(SteamAPICall_t apiCall, CCallbackBase *callback);
 	void UnRegisterAPICallResult(SteamAPICall_t apiCall, CCallbackBase *callback);
 
+	void Cleanup();
+
 	HSteamUser currentUser;
 private:
 	void RunAPICallbacks(HSteamPipe pipe, SteamAPICallCompleted_t *call);

File steam_api/steam_api.cpp

 		steamclient->ReleaseSteamPipe(pipe);
 		pipe = NULL;
 	}
+
+	callbackmanager.Cleanup();
 }