mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-08 19:23:28 +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() {
|
||||
gl_monitorMapProtect.lock();
|
||||
TMonitorMap::iterator lookup = gl_monitorMap.find(context);
|
||||
TMonitorMap::iterator lookup = gl_monitorMap.find(_context);
|
||||
if (lookup != gl_monitorMap.end()) {
|
||||
gl_monitorMap.erase(lookup);
|
||||
}
|
||||
gl_monitorMapProtect.unlock();
|
||||
}
|
||||
|
||||
RestrictedContextMonitor::TSharedPtr RestrictedContextMonitor::getMonitor(QQmlContext* context, bool createIfMissing) {
|
||||
TSharedPtr monitor;
|
||||
RestrictedContextMonitor::TSharedPointer RestrictedContextMonitor::getMonitor(QQmlContext* context, bool createIfMissing) {
|
||||
TSharedPointer monitor;
|
||||
|
||||
gl_monitorMapProtect.lock();
|
||||
TMonitorMap::const_iterator lookup = gl_monitorMap.find(context);
|
||||
|
@ -41,8 +41,8 @@ RestrictedContextMonitor::TSharedPtr RestrictedContextMonitor::getMonitor(QQmlCo
|
|||
monitor = lookup->second.lock();
|
||||
assert(monitor);
|
||||
} else if(createIfMissing) {
|
||||
monitor = std::make_shared<RestrictedContextMonitor>(context);
|
||||
monitor->selfPtr = monitor;
|
||||
monitor = TSharedPointer::create(context);
|
||||
monitor->_selfPointer = monitor;
|
||||
gl_monitorMap.insert(TMonitorMap::value_type(context, monitor));
|
||||
}
|
||||
gl_monitorMapProtect.unlock();
|
||||
|
@ -55,19 +55,19 @@ ContextAwareProfile::ContextAwareProfile(QQmlContext* context) : ContextAwarePro
|
|||
_monitor = RestrictedContextMonitor::getMonitor(context, true);
|
||||
assert(_monitor);
|
||||
connect(_monitor.get(), &RestrictedContextMonitor::onIsRestrictedChanged, this, &ContextAwareProfile::onIsRestrictedChanged);
|
||||
if (_monitor->isUninitialized) {
|
||||
_monitor->isRestricted = isRestrictedGetProperty();
|
||||
_monitor->isUninitialized = false;
|
||||
if (_monitor->_isUninitialized) {
|
||||
_monitor->_isRestricted = isRestrictedGetProperty();
|
||||
_monitor->_isUninitialized = false;
|
||||
}
|
||||
_isRestricted.store(_monitor->isRestricted ? 1 : 0);
|
||||
_isRestricted.store(_monitor->_isRestricted ? 1 : 0);
|
||||
}
|
||||
|
||||
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);
|
||||
if (monitor && monitor->isRestricted != restrict) {
|
||||
monitor->isRestricted = restrict;
|
||||
if (monitor && monitor->_isRestricted != restrict) {
|
||||
monitor->_isRestricted = restrict;
|
||||
monitor->onIsRestrictedChanged(restrict);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
|
||||
#include <QtCore/QtGlobal>
|
||||
#include <QtCore/QMutex>
|
||||
#include <QtCore/QSharedPointer>
|
||||
|
||||
#if !defined(Q_OS_ANDROID)
|
||||
#include <QtWebEngine/QQuickWebEngineProfile>
|
||||
|
@ -34,25 +35,25 @@ class QQmlContext;
|
|||
class RestrictedContextMonitor : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
typedef std::shared_ptr<RestrictedContextMonitor> TSharedPtr;
|
||||
typedef std::weak_ptr<RestrictedContextMonitor> TWeakPtr;
|
||||
typedef QSharedPointer<RestrictedContextMonitor> TSharedPointer;
|
||||
typedef QWeakPointer<RestrictedContextMonitor> TWeakPointer;
|
||||
|
||||
inline RestrictedContextMonitor(QQmlContext* c) : context(c) {}
|
||||
inline RestrictedContextMonitor(QQmlContext* c) : _context(c) {}
|
||||
~RestrictedContextMonitor();
|
||||
|
||||
static TSharedPtr getMonitor(QQmlContext* context, bool createIfMissing);
|
||||
static TSharedPointer getMonitor(QQmlContext* context, bool createIfMissing);
|
||||
|
||||
signals:
|
||||
void onIsRestrictedChanged(bool newValue);
|
||||
|
||||
public:
|
||||
TWeakPtr selfPtr;
|
||||
QQmlContext* context{ nullptr };
|
||||
bool isRestricted{ true };
|
||||
bool isUninitialized{ true };
|
||||
TWeakPointer _selfPointer;
|
||||
QQmlContext* _context{ nullptr };
|
||||
bool _isRestricted{ true };
|
||||
bool _isUninitialized{ true };
|
||||
|
||||
private:
|
||||
typedef std::map<QQmlContext*, TWeakPtr> TMonitorMap;
|
||||
typedef std::map<QQmlContext*, TWeakPointer> TMonitorMap;
|
||||
|
||||
static QMutex gl_monitorMapProtect;
|
||||
static TMonitorMap gl_monitorMap;
|
||||
|
@ -82,7 +83,7 @@ private slots:
|
|||
void onIsRestrictedChanged(bool newValue);
|
||||
|
||||
private:
|
||||
RestrictedContextMonitor::TSharedPtr _monitor;
|
||||
RestrictedContextMonitor::TSharedPointer _monitor;
|
||||
};
|
||||
|
||||
#endif // hifi_FileTypeProfile_h
|
||||
|
|
Loading…
Reference in a new issue