From 17333720e05bbe5d84d246c0850c8c2c047a141e Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 29 Nov 2013 12:06:45 +0100 Subject: Minimal plugin: Use a dummy font database for command line tools. Suppress warnings like: QFontDatabase: Cannot find font directory '...' - is Qt installed correctly? occurring for example when using qmlplugindump. Add option flags (similar to Windows plugin) to the integration class to be used for QT_DEBUG_BACKINGSTORE and other functionality. Add a dummy font database with empty populate() function to be used unless the debug flag for the backing store is used. Task-number: QTBUG-33674 Task-number: QTCREATORBUG-10685 Change-Id: I7eaff3025de12e6b0471a3430f986b0cd810e22c Reviewed-by: Paul Olav Tvete --- .../platforms/minimal/qminimalintegration.cpp | 50 +++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) (limited to 'src/plugins/platforms/minimal/qminimalintegration.cpp') diff --git a/src/plugins/platforms/minimal/qminimalintegration.cpp b/src/plugins/platforms/minimal/qminimalintegration.cpp index a08cede76a..76b4b5b0eb 100644 --- a/src/plugins/platforms/minimal/qminimalintegration.cpp +++ b/src/plugins/platforms/minimal/qminimalintegration.cpp @@ -50,11 +50,31 @@ #include #include #include +#include QT_BEGIN_NAMESPACE -QMinimalIntegration::QMinimalIntegration() +static const char debugBackingStoreEnvironmentVariable[] = "QT_DEBUG_BACKINGSTORE"; + +static inline unsigned parseOptions(const QStringList ¶mList) +{ + unsigned options = 0; + foreach (const QString ¶m, paramList) { + if (param == QLatin1String("enable_fonts")) + options |= QMinimalIntegration::EnableFonts; + } + return options; +} + +QMinimalIntegration::QMinimalIntegration(const QStringList ¶meters) + : m_dummyFontDatabase(0) + , m_options(parseOptions(parameters)) { + if (qEnvironmentVariableIsSet(debugBackingStoreEnvironmentVariable) + && qgetenv(debugBackingStoreEnvironmentVariable).toInt() > 0) { + m_options |= DebugBackingStore | EnableFonts; + } + QMinimalScreen *mPrimaryScreen = new QMinimalScreen(); mPrimaryScreen->mGeometry = QRect(0, 0, 240, 320); @@ -64,6 +84,11 @@ QMinimalIntegration::QMinimalIntegration() screenAdded(mPrimaryScreen); } +QMinimalIntegration::~QMinimalIntegration() +{ + delete m_dummyFontDatabase; +} + bool QMinimalIntegration::hasCapability(QPlatformIntegration::Capability cap) const { switch (cap) { @@ -73,6 +98,24 @@ bool QMinimalIntegration::hasCapability(QPlatformIntegration::Capability cap) co } } +// Dummy font database that does not scan the fonts directory to be +// used for command line tools like qmlplugindump that do not create windows +// unless DebugBackingStore is activated. +class DummyFontDatabase : public QPlatformFontDatabase +{ +public: + virtual void populateFontDatabase() {} +}; + +QPlatformFontDatabase *QMinimalIntegration::fontDatabase() const +{ + if (m_options & EnableFonts) + return QPlatformIntegration::fontDatabase(); + if (!m_dummyFontDatabase) + m_dummyFontDatabase = new DummyFontDatabase; + return m_dummyFontDatabase; +} + QPlatformWindow *QMinimalIntegration::createPlatformWindow(QWindow *window) const { Q_UNUSED(window); @@ -95,4 +138,9 @@ QAbstractEventDispatcher *QMinimalIntegration::createEventDispatcher() const #endif } +QMinimalIntegration *QMinimalIntegration::instance() +{ + return static_cast(QGuiApplicationPrivate::platformIntegration()); +} + QT_END_NAMESPACE -- cgit v1.2.3