QQmlEngine: some more cleanup

Remove dead code, initialize members inline, write "emit" when emitting
signals.

Change-Id: If7ba5a9235abb9b605194db727847a7e035e5529
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
This commit is contained in:
Ulf Hermann 2021-12-03 01:25:31 +01:00
parent c9112c210f
commit ccd6192992
2 changed files with 16 additions and 43 deletions

View File

@ -240,26 +240,6 @@ QQmlImageProviderBase::~QQmlImageProviderBase()
{
}
QQmlEnginePrivate::QQmlEnginePrivate(QQmlEngine *e)
: propertyCapture(nullptr), rootContext(nullptr),
#if QT_CONFIG(qml_debug)
profiler(nullptr),
#endif
outputWarningsToMsgLog(true),
erroredBindings(nullptr), inProgressCreations(0),
#if QT_CONFIG(qml_worker_script)
workerScriptEngine(nullptr),
#endif
activeObjectCreator(nullptr),
#if QT_CONFIG(qml_network)
networkAccessManager(nullptr), networkAccessManagerFactory(nullptr),
#endif
scarceResourcesRefCount(0), importDatabase(e), typeLoader(e),
uniqueId(1), incubatorCount(0), incubationController(nullptr)
{
}
QQmlEnginePrivate::~QQmlEnginePrivate()
{
if (inProgressCreations)
@ -1445,7 +1425,7 @@ static void dumpwarning(const QList<QQmlError> &errors)
void QQmlEnginePrivate::warning(const QQmlError &error)
{
Q_Q(QQmlEngine);
q->warnings(QList<QQmlError>() << error);
emit q->warnings(QList<QQmlError>({error}));
if (outputWarningsToMsgLog)
dumpwarning(error);
}
@ -1453,7 +1433,7 @@ void QQmlEnginePrivate::warning(const QQmlError &error)
void QQmlEnginePrivate::warning(const QList<QQmlError> &errors)
{
Q_Q(QQmlEngine);
q->warnings(errors);
emit q->warnings(errors);
if (outputWarningsToMsgLog)
dumpwarning(errors);
}

View File

@ -135,7 +135,7 @@ class Q_QML_PRIVATE_EXPORT QQmlEnginePrivate : public QJSEnginePrivate
{
Q_DECLARE_PUBLIC(QQmlEngine)
public:
QQmlEnginePrivate(QQmlEngine *);
explicit QQmlEnginePrivate(QQmlEngine *q) : importDatabase(q), typeLoader(q) {}
~QQmlEnginePrivate() override;
void init();
@ -143,47 +143,47 @@ public:
// is just qmlClearTypeRegistrations (which can't be called while an engine exists)
static bool baseModulesUninitialized;
QQmlPropertyCapture *propertyCapture;
QQmlPropertyCapture *propertyCapture = nullptr;
QRecyclePool<QQmlJavaScriptExpressionGuard> jsExpressionGuardPool;
QRecyclePool<TriggerList> qPropertyTriggerPool;
QQmlContext *rootContext;
QQmlContext *rootContext = nullptr;
Q_OBJECT_BINDABLE_PROPERTY(QQmlEnginePrivate, QString, translationLanguage);
#if !QT_CONFIG(qml_debug)
static const quintptr profiler = 0;
#else
QQmlProfiler *profiler;
QQmlProfiler *profiler = nullptr;
#endif
bool outputWarningsToMsgLog;
bool outputWarningsToMsgLog = true;
// Bindings that have had errors during startup
QQmlDelayedError *erroredBindings;
int inProgressCreations;
QQmlDelayedError *erroredBindings = nullptr;
int inProgressCreations = 0;
QV4::ExecutionEngine *v4engine() const { return q_func()->handle(); }
#if QT_CONFIG(qml_worker_script)
QThread *workerScriptEngine;
QThread *workerScriptEngine = nullptr;
#endif
QUrl baseUrl;
QQmlObjectCreator *activeObjectCreator;
QQmlObjectCreator *activeObjectCreator = nullptr;
#if QT_CONFIG(qml_network)
QNetworkAccessManager *createNetworkAccessManager(QObject *parent) const;
QNetworkAccessManager *getNetworkAccessManager() const;
mutable QNetworkAccessManager *networkAccessManager;
mutable QQmlNetworkAccessManagerFactory *networkAccessManagerFactory;
mutable QNetworkAccessManager *networkAccessManager = nullptr;
mutable QQmlNetworkAccessManagerFactory *networkAccessManagerFactory = nullptr;
#endif
QHash<QString,QSharedPointer<QQmlImageProviderBase> > imageProviders;
QSharedPointer<QQmlImageProviderBase> imageProvider(const QString &providerId) const;
QList<QQmlAbstractUrlInterceptor *> urlInterceptors;
int scarceResourcesRefCount;
int scarceResourcesRefCount = 0;
void referenceScarceResources();
void dereferenceScarceResources();
@ -192,11 +192,6 @@ public:
QString offlineStoragePath;
mutable quint32 uniqueId;
inline quint32 getUniqueId() const {
return uniqueId++;
}
// Unfortunate workaround to avoid a circular dependency between
// qqmlengine_p.h and qqmlincubator_p.h
struct Incubator : public QSharedData {
@ -205,8 +200,8 @@ public:
QIntrusiveListNode nextWaitingFor;
};
QIntrusiveList<Incubator, &Incubator::next> incubatorList;
unsigned int incubatorCount;
QQmlIncubationController *incubationController;
unsigned int incubatorCount = 0;
QQmlIncubationController *incubationController = nullptr;
void incubate(QQmlIncubator &, const QQmlRefPointer<QQmlContextData> &);
// These methods may be called from any thread
@ -252,8 +247,6 @@ public:
static QList<QQmlError> qmlErrorFromDiagnostics(const QString &fileName, const QList<QQmlJS::DiagnosticMessage> &diagnosticMessages);
static void defineModule();
static bool designerMode();
static void activateDesignerMode();