Player: Fix a deadlock triggered by previous commit 0e5e49736c

master
Loic Blot 2015-03-22 21:33:09 +01:00
parent 0e5e49736c
commit 0ae75f2a4e
2 changed files with 3 additions and 2 deletions

View File

@ -20,6 +20,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "player.h" #include "player.h"
#include <fstream> #include <fstream>
#include "jthread/jmutexautolock.h"
#include "util/numeric.h" #include "util/numeric.h"
#include "hud.h" #include "hud.h"
#include "constants.h" #include "constants.h"
@ -241,6 +242,7 @@ void Player::deSerialize(std::istream &is, std::string playername)
u32 Player::addHud(HudElement *toadd) u32 Player::addHud(HudElement *toadd)
{ {
JMutexAutoLock lock(m_mutex); JMutexAutoLock lock(m_mutex);
u32 id = getFreeHudID(); u32 id = getFreeHudID();
if (id < hud.size()) if (id < hud.size())

View File

@ -23,7 +23,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "irrlichttypes_bloated.h" #include "irrlichttypes_bloated.h"
#include "inventory.h" #include "inventory.h"
#include "constants.h" // BS #include "constants.h" // BS
#include "jthread/jmutexautolock.h" #include "jthread/jmutex.h"
#include <list> #include <list>
#define PLAYERNAME_SIZE 20 #define PLAYERNAME_SIZE 20
@ -204,7 +204,6 @@ public:
} }
u32 getFreeHudID() { u32 getFreeHudID() {
JMutexAutoLock lock(m_mutex);
size_t size = hud.size(); size_t size = hud.size();
for (size_t i = 0; i != size; i++) { for (size_t i = 0; i != size; i++) {
if (!hud[i]) if (!hud[i])