mirror of
https://github.com/overte-org/overte.git
synced 2025-04-13 16:24:47 +02:00
cleaned up variables names, replaced std::shared_ptr with QSharedPointer
This commit is contained in:
parent
61e6e8dfc9
commit
84a8c640e4
2 changed files with 23 additions and 22 deletions
|
@ -25,15 +25,15 @@ RestrictedContextMonitor::TMonitorMap RestrictedContextMonitor::gl_monitorMap;
|
||||||
|
|
||||||
RestrictedContextMonitor::~RestrictedContextMonitor() {
|
RestrictedContextMonitor::~RestrictedContextMonitor() {
|
||||||
gl_monitorMapProtect.lock();
|
gl_monitorMapProtect.lock();
|
||||||
TMonitorMap::iterator lookup = gl_monitorMap.find(context);
|
TMonitorMap::iterator lookup = gl_monitorMap.find(_context);
|
||||||
if (lookup != gl_monitorMap.end()) {
|
if (lookup != gl_monitorMap.end()) {
|
||||||
gl_monitorMap.erase(lookup);
|
gl_monitorMap.erase(lookup);
|
||||||
}
|
}
|
||||||
gl_monitorMapProtect.unlock();
|
gl_monitorMapProtect.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
RestrictedContextMonitor::TSharedPtr RestrictedContextMonitor::getMonitor(QQmlContext* context, bool createIfMissing) {
|
RestrictedContextMonitor::TSharedPointer RestrictedContextMonitor::getMonitor(QQmlContext* context, bool createIfMissing) {
|
||||||
TSharedPtr monitor;
|
TSharedPointer monitor;
|
||||||
|
|
||||||
gl_monitorMapProtect.lock();
|
gl_monitorMapProtect.lock();
|
||||||
TMonitorMap::const_iterator lookup = gl_monitorMap.find(context);
|
TMonitorMap::const_iterator lookup = gl_monitorMap.find(context);
|
||||||
|
@ -41,8 +41,8 @@ RestrictedContextMonitor::TSharedPtr RestrictedContextMonitor::getMonitor(QQmlCo
|
||||||
monitor = lookup->second.lock();
|
monitor = lookup->second.lock();
|
||||||
assert(monitor);
|
assert(monitor);
|
||||||
} else if(createIfMissing) {
|
} else if(createIfMissing) {
|
||||||
monitor = std::make_shared<RestrictedContextMonitor>(context);
|
monitor = TSharedPointer::create(context);
|
||||||
monitor->selfPtr = monitor;
|
monitor->_selfPointer = monitor;
|
||||||
gl_monitorMap.insert(TMonitorMap::value_type(context, monitor));
|
gl_monitorMap.insert(TMonitorMap::value_type(context, monitor));
|
||||||
}
|
}
|
||||||
gl_monitorMapProtect.unlock();
|
gl_monitorMapProtect.unlock();
|
||||||
|
@ -55,19 +55,19 @@ ContextAwareProfile::ContextAwareProfile(QQmlContext* context) : ContextAwarePro
|
||||||
_monitor = RestrictedContextMonitor::getMonitor(context, true);
|
_monitor = RestrictedContextMonitor::getMonitor(context, true);
|
||||||
assert(_monitor);
|
assert(_monitor);
|
||||||
connect(_monitor.get(), &RestrictedContextMonitor::onIsRestrictedChanged, this, &ContextAwareProfile::onIsRestrictedChanged);
|
connect(_monitor.get(), &RestrictedContextMonitor::onIsRestrictedChanged, this, &ContextAwareProfile::onIsRestrictedChanged);
|
||||||
if (_monitor->isUninitialized) {
|
if (_monitor->_isUninitialized) {
|
||||||
_monitor->isRestricted = isRestrictedGetProperty();
|
_monitor->_isRestricted = isRestrictedGetProperty();
|
||||||
_monitor->isUninitialized = false;
|
_monitor->_isUninitialized = false;
|
||||||
}
|
}
|
||||||
_isRestricted.store(_monitor->isRestricted ? 1 : 0);
|
_isRestricted.store(_monitor->_isRestricted ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContextAwareProfile::restrictContext(QQmlContext* context, bool restrict) {
|
void ContextAwareProfile::restrictContext(QQmlContext* context, bool restrict) {
|
||||||
RestrictedContextMonitor::TSharedPtr monitor = RestrictedContextMonitor::getMonitor(context, false);
|
RestrictedContextMonitor::TSharedPointer monitor = RestrictedContextMonitor::getMonitor(context, false);
|
||||||
|
|
||||||
context->setContextProperty(RESTRICTED_FLAG_PROPERTY, restrict);
|
context->setContextProperty(RESTRICTED_FLAG_PROPERTY, restrict);
|
||||||
if (monitor && monitor->isRestricted != restrict) {
|
if (monitor && monitor->_isRestricted != restrict) {
|
||||||
monitor->isRestricted = restrict;
|
monitor->_isRestricted = restrict;
|
||||||
monitor->onIsRestrictedChanged(restrict);
|
monitor->onIsRestrictedChanged(restrict);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
|
|
||||||
#include <QtCore/QtGlobal>
|
#include <QtCore/QtGlobal>
|
||||||
#include <QtCore/QMutex>
|
#include <QtCore/QMutex>
|
||||||
|
#include <QtCore/QSharedPointer>
|
||||||
|
|
||||||
#if !defined(Q_OS_ANDROID)
|
#if !defined(Q_OS_ANDROID)
|
||||||
#include <QtWebEngine/QQuickWebEngineProfile>
|
#include <QtWebEngine/QQuickWebEngineProfile>
|
||||||
|
@ -34,25 +35,25 @@ class QQmlContext;
|
||||||
class RestrictedContextMonitor : public QObject {
|
class RestrictedContextMonitor : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
typedef std::shared_ptr<RestrictedContextMonitor> TSharedPtr;
|
typedef QSharedPointer<RestrictedContextMonitor> TSharedPointer;
|
||||||
typedef std::weak_ptr<RestrictedContextMonitor> TWeakPtr;
|
typedef QWeakPointer<RestrictedContextMonitor> TWeakPointer;
|
||||||
|
|
||||||
inline RestrictedContextMonitor(QQmlContext* c) : context(c) {}
|
inline RestrictedContextMonitor(QQmlContext* c) : _context(c) {}
|
||||||
~RestrictedContextMonitor();
|
~RestrictedContextMonitor();
|
||||||
|
|
||||||
static TSharedPtr getMonitor(QQmlContext* context, bool createIfMissing);
|
static TSharedPointer getMonitor(QQmlContext* context, bool createIfMissing);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void onIsRestrictedChanged(bool newValue);
|
void onIsRestrictedChanged(bool newValue);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TWeakPtr selfPtr;
|
TWeakPointer _selfPointer;
|
||||||
QQmlContext* context{ nullptr };
|
QQmlContext* _context{ nullptr };
|
||||||
bool isRestricted{ true };
|
bool _isRestricted{ true };
|
||||||
bool isUninitialized{ true };
|
bool _isUninitialized{ true };
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef std::map<QQmlContext*, TWeakPtr> TMonitorMap;
|
typedef std::map<QQmlContext*, TWeakPointer> TMonitorMap;
|
||||||
|
|
||||||
static QMutex gl_monitorMapProtect;
|
static QMutex gl_monitorMapProtect;
|
||||||
static TMonitorMap gl_monitorMap;
|
static TMonitorMap gl_monitorMap;
|
||||||
|
@ -82,7 +83,7 @@ private slots:
|
||||||
void onIsRestrictedChanged(bool newValue);
|
void onIsRestrictedChanged(bool newValue);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
RestrictedContextMonitor::TSharedPtr _monitor;
|
RestrictedContextMonitor::TSharedPointer _monitor;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_FileTypeProfile_h
|
#endif // hifi_FileTypeProfile_h
|
||||||
|
|
Loading…
Reference in a new issue