Fixed first startup of STK (i.e. when no config.xml exist, and the

user is asked if he wants to connect). Fixed also some problems
with enabling/disabling internet news in the GUI.


git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@8658 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
hikerstk
2011-05-22 14:09:02 +00:00
parent 7aac279fc8
commit 3ba9407518
3 changed files with 21 additions and 8 deletions

View File

@@ -63,8 +63,8 @@ NetworkHttp *network_http=NULL;
* ending up with an corrupted file).
*/
NetworkHttp::NetworkHttp() : m_all_requests(std::vector<Request*>()),
m_current_request(NULL),
m_abort(false),
m_current_request(NULL),
m_abort(false),
m_thread_id(NULL)
{
// Don't even start the network threads if networking is disabled.
@@ -94,6 +94,9 @@ NetworkHttp::NetworkHttp() : m_all_requests(std::vector<Request*>()),
*/
void NetworkHttp::startNetworkThread()
{
if(UserConfigParams::m_internet_status!=NetworkHttp::IPERM_ALLOWED )
return;
pthread_attr_t attr;
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
@@ -225,9 +228,8 @@ void NetworkHttp::stopNetworkThread()
*/
NetworkHttp::~NetworkHttp()
{
if(UserConfigParams::logAddons())
printf("[addons] Command mutex unlocked.\n");
if(UserConfigParams::m_internet_status!=NetworkHttp::IPERM_ALLOWED)
return;
m_thread_id.lock();
if(m_thread_id.getData())

View File

@@ -22,6 +22,7 @@
#include <iostream>
#include <string>
#include "addons/network_http.hpp"
#include "graphics/irr_driver.hpp"
#include "guiengine/scalable_font.hpp"
#include "guiengine/widgets/label_widget.hpp"
@@ -103,7 +104,8 @@ void MainMenuScreen::init()
input_manager->getDeviceList()->clearLatestUsedDevice();
#ifdef ADDONS_MANAGER
if(!addons_manager->onlineReady())
if(!addons_manager->onlineReady() ||
UserConfigParams::m_internet_status!=NetworkHttp::IPERM_ALLOWED )
{
IconButtonWidget* w = this->getWidget<IconButtonWidget>("addons");
w->setDeactivated();
@@ -123,7 +125,8 @@ void MainMenuScreen::onUpdate(float delta, irr::video::IVideoDriver* driver)
IconButtonWidget* addons_icon = this->getWidget<IconButtonWidget>("addons");
if (addons_icon != NULL)
{
if(!addons_manager->onlineReady())
if(!addons_manager->onlineReady() ||
UserConfigParams::m_internet_status!=NetworkHttp::IPERM_ALLOWED )
addons_icon->setDeactivated();
else
addons_icon->setActivated();

View File

@@ -190,11 +190,19 @@ void OptionsScreenUI::eventCallback(Widget* widget, const std::string& name, con
{
CheckBoxWidget* news = getWidget<CheckBoxWidget>("enable-internet");
assert( news != NULL );
delete network_http;
if(network_http)
{
network_http->stopNetworkThread();
delete network_http;
}
UserConfigParams::m_internet_status =
news->getState() ? NetworkHttp::IPERM_ALLOWED
: NetworkHttp::IPERM_NOT_ALLOWED;
network_http = new NetworkHttp();
// Note that the network thread must be started after the assignment
// to network_http (since the thread might use network_http, otherwise
// a race condition can be introduced resulting in a crash).
network_http->startNetworkThread();
}
else if (name=="minimal-racegui")
{