Qt 4.8
Functions | Variables
qnetworkconfigmanager.cpp File Reference
#include "qnetworkconfigmanager.h"
#include "qnetworkconfigmanager_p.h"
#include "qbearerengine_p.h"
#include <QtCore/qstringlist.h>
#include <QtCore/qcoreapplication.h>
#include <QtCore/qmutex.h>
#include <QtCore/qthread.h>
#include <QtCore/private/qcoreapplication_p.h>
#include "moc_qnetworkconfigmanager.cpp"

Go to the source code of this file.

Functions

static QNetworkConfigurationManagerPrivateconnManager ()
 
static void connManager_cleanup ()
 
QNetworkConfigurationManagerPrivateqNetworkConfigurationManagerPrivate ()
 

Variables

static QBasicAtomicInt appShutdown
 
static QBasicAtomicPointer< QNetworkConfigurationManagerPrivateconnManager_ptr
 

Function Documentation

◆ connManager()

static QNetworkConfigurationManagerPrivate* connManager ( )
static

Definition at line 76 of file qnetworkconfigmanager.cpp.

Referenced by QNetworkConfigurationManager::allConfigurations(), QNetworkConfigurationManager::capabilities(), QNetworkConfigurationManager::configurationFromIdentifier(), QNetworkConfigurationManager::defaultConfiguration(), QNetworkConfigurationManager::isOnline(), qNetworkConfigurationManagerPrivate(), QNetworkConfigurationManager::updateConfigurations(), and QNetworkConfigurationManager::~QNetworkConfigurationManager().

77 {
79  if (!ptr && !appShutdown) {
80  QMutexLocker locker(connManager_mutex());
81  if (!(ptr = connManager_ptr.fetchAndAddAcquire(0))) {
83 
85  // right thread or no main thread yet
86  ptr->addPostRoutine();
87  ptr->initialize();
88  } else {
89  // wrong thread, we need to make the main thread do this
90  QObject *obj = new QObject;
91  QObject::connect(obj, SIGNAL(destroyed()), ptr, SLOT(addPostRoutine()), Qt::DirectConnection);
92  ptr->initialize(); // this moves us to the right thread
94  obj->deleteLater();
95  }
96 
97  connManager_ptr.fetchAndStoreRelease(ptr);
98  }
99  }
100  return ptr;
101 }
static QBasicAtomicPointer< QNetworkConfigurationManagerPrivate > connManager_ptr
#define SLOT(a)
Definition: qobjectdefs.h:226
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
#define SIGNAL(a)
Definition: qobjectdefs.h:227
static QBasicAtomicInt appShutdown
static QThread * currentThread()
Returns a pointer to a QThread which manages the currently executing thread.
Definition: qthread.cpp:419
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
Definition: qobject.cpp:2580
void moveToThread(QThread *thread)
Changes the thread affinity for this object and its children.
Definition: qobject.cpp:1458
const T * ptr(const T &t)
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
static QThread * mainThread()
void deleteLater()
Schedules this object for deletion.
Definition: qobject.cpp:2145

◆ connManager_cleanup()

static void connManager_cleanup ( )
static

Definition at line 61 of file qnetworkconfigmanager.cpp.

Referenced by QNetworkConfigurationManagerPrivate::addPostRoutine().

62 {
63  // this is not atomic or thread-safe!
64  int shutdown = appShutdown.fetchAndStoreAcquire(1);
65  Q_ASSERT(shutdown == 0);
66  if(connManager_ptr)
67  connManager_ptr->cleanup();
68  connManager_ptr = 0;
69 }
static QBasicAtomicPointer< QNetworkConfigurationManagerPrivate > connManager_ptr
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
static QBasicAtomicInt appShutdown
int fetchAndStoreAcquire(int newValue)

◆ qNetworkConfigurationManagerPrivate()

QNetworkConfigurationManagerPrivate* qNetworkConfigurationManagerPrivate ( )

Definition at line 103 of file qnetworkconfigmanager.cpp.

Referenced by getEngineFromId(), QNetworkConfigurationManager::QNetworkConfigurationManager(), and QNetworkSession::QNetworkSession().

104 {
105  return connManager();
106 }
static QNetworkConfigurationManagerPrivate * connManager()

Variable Documentation

◆ appShutdown

QBasicAtomicInt appShutdown
static

Definition at line 59 of file qnetworkconfigmanager.cpp.

Referenced by connManager().

◆ connManager_ptr

Definition at line 57 of file qnetworkconfigmanager.cpp.