Fixed crash at end if threads could not be created. Added appropriate
warning, and made more prints depend on verbosity level. git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@8097 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
51c134c2af
commit
6bd2d0b3b5
@ -18,6 +18,7 @@
|
||||
#include "addons/network_http.hpp"
|
||||
|
||||
#include <curl/curl.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <string>
|
||||
|
||||
@ -76,7 +77,12 @@ NetworkHttp::NetworkHttp() : m_news(std::vector<NewsMessage>()),
|
||||
pthread_attr_t attr;
|
||||
pthread_attr_init(&attr);
|
||||
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
|
||||
pthread_create(&m_thread_id, &attr, &NetworkHttp::mainLoop, this);
|
||||
int error=pthread_create(&m_thread_id, &attr, &NetworkHttp::mainLoop, this);
|
||||
if(error)
|
||||
{
|
||||
m_thread_id = 0;
|
||||
printf("[addons] Warning: could not create thread, error=%d.\n", errno);
|
||||
}
|
||||
pthread_attr_destroy(&attr);
|
||||
} // NetworkHttp
|
||||
|
||||
@ -193,11 +199,16 @@ NetworkHttp::~NetworkHttp()
|
||||
pthread_cond_signal(&m_cond_command);
|
||||
}
|
||||
pthread_mutex_unlock(&m_mutex_command);
|
||||
printf("[addons] Mutex unlocked.\n");
|
||||
if(UserConfigParams::m_verbosity>=3)
|
||||
printf("[addons] Mutex unlocked.\n");
|
||||
|
||||
void *result;
|
||||
pthread_join(m_thread_id, &result);
|
||||
printf("[addons] Network thread joined.\n");
|
||||
if(m_thread_id)
|
||||
{
|
||||
void *result;
|
||||
pthread_join(m_thread_id, &result);
|
||||
if(UserConfigParams::m_verbosity>=3)
|
||||
printf("[addons] Network thread joined.\n");
|
||||
}
|
||||
|
||||
pthread_mutex_destroy(&m_mutex_command);
|
||||
pthread_cond_destroy(&m_cond_command);
|
||||
|
@ -580,10 +580,10 @@ void MinimalRaceGUI::drawRankLap(const KartIconDisplayInfo* info,
|
||||
- m_lap_width -20 );
|
||||
pos.UpperLeftCorner.Y = viewport.LowerRightCorner.Y-60;
|
||||
|
||||
printf("x %d %d\n", pos.UpperLeftCorner.Y, pos.LowerRightCorner.Y);
|
||||
char str[256];
|
||||
sprintf(str, "%d/%d", lap+1, race_manager->getNumLaps());
|
||||
core::stringw s = m_string_lap+" "+str;
|
||||
float scale = font->getScale();
|
||||
font->draw(s.c_str(), pos, color);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user