From 52c8d9ffbabc05c8f6cd7d2a21c109afb6aae8d1 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Tue, 15 Oct 2013 12:55:11 +0200 Subject: linuxfb: Adapt to initialize() pattern MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Migrate to the new 5.2 pattern: Prevent relying on the event dispatcher in the constructor by performing initialization later in initialize() instead. Change-Id: Ifa6024affc35e995d6e33a63fa813da9df0c491b Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp | 11 ++++++++--- src/plugins/platforms/linuxfb/qlinuxfbintegration.h | 14 ++++++++------ src/plugins/platforms/linuxfb/qlinuxfbscreen.cpp | 8 ++++---- src/plugins/platforms/linuxfb/qlinuxfbscreen.h | 5 +++-- 4 files changed, 23 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp b/src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp index aa2687da30..977df8abd0 100644 --- a/src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp +++ b/src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp @@ -56,9 +56,8 @@ QT_BEGIN_NAMESPACE QLinuxFbIntegration::QLinuxFbIntegration(const QStringList ¶mList) : m_fontDb(new QGenericUnixFontDatabase()) { - m_primaryScreen = new QLinuxFbScreen; - if (m_primaryScreen->initialize(paramList)) - screenAdded(m_primaryScreen); + m_primaryScreen = new QLinuxFbScreen(paramList); + screenAdded(m_primaryScreen); } QLinuxFbIntegration::~QLinuxFbIntegration() @@ -66,6 +65,12 @@ QLinuxFbIntegration::~QLinuxFbIntegration() delete m_primaryScreen; } +void QLinuxFbIntegration::initialize() +{ + if (!m_primaryScreen->initialize()) + qWarning("linuxfb: Failed to initialize screen"); +} + bool QLinuxFbIntegration::hasCapability(QPlatformIntegration::Capability cap) const { switch (cap) { diff --git a/src/plugins/platforms/linuxfb/qlinuxfbintegration.h b/src/plugins/platforms/linuxfb/qlinuxfbintegration.h index 6de9ac9992..a213f83c6f 100644 --- a/src/plugins/platforms/linuxfb/qlinuxfbintegration.h +++ b/src/plugins/platforms/linuxfb/qlinuxfbintegration.h @@ -56,14 +56,16 @@ public: QLinuxFbIntegration(const QStringList ¶mList); ~QLinuxFbIntegration(); - bool hasCapability(QPlatformIntegration::Capability cap) const; + void initialize() Q_DECL_OVERRIDE; + bool hasCapability(QPlatformIntegration::Capability cap) const Q_DECL_OVERRIDE; + + QPlatformPixmap *createPlatformPixmap(QPlatformPixmap::PixelType type) const Q_DECL_OVERRIDE; + QPlatformWindow *createPlatformWindow(QWindow *window) const Q_DECL_OVERRIDE; + QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const Q_DECL_OVERRIDE; + QAbstractEventDispatcher *createEventDispatcher() const Q_DECL_OVERRIDE; + QPlatformFontDatabase *fontDatabase() const Q_DECL_OVERRIDE; - QPlatformPixmap *createPlatformPixmap(QPlatformPixmap::PixelType type) const; - QPlatformWindow *createPlatformWindow(QWindow *window) const; - QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const; - QAbstractEventDispatcher *createEventDispatcher() const; QList screens() const; - QPlatformFontDatabase *fontDatabase() const; private: QLinuxFbScreen *m_primaryScreen; diff --git a/src/plugins/platforms/linuxfb/qlinuxfbscreen.cpp b/src/plugins/platforms/linuxfb/qlinuxfbscreen.cpp index 6a2d767723..4f9284da7f 100644 --- a/src/plugins/platforms/linuxfb/qlinuxfbscreen.cpp +++ b/src/plugins/platforms/linuxfb/qlinuxfbscreen.cpp @@ -296,8 +296,8 @@ static void blankScreen(int fd, bool on) ioctl(fd, FBIOBLANK, on ? VESA_POWERDOWN : VESA_NO_BLANKING); } -QLinuxFbScreen::QLinuxFbScreen() - : mFbFd(-1), mBlitter(0) +QLinuxFbScreen::QLinuxFbScreen(const QStringList &args) + : mArgs(args), mFbFd(-1), mBlitter(0) { } @@ -316,7 +316,7 @@ QLinuxFbScreen::~QLinuxFbScreen() delete mBlitter; } -bool QLinuxFbScreen::initialize(const QStringList &args) +bool QLinuxFbScreen::initialize() { QRegExp ttyRx(QLatin1String("tty=(.*)")); QRegExp fbRx(QLatin1String("fb=(.*)")); @@ -330,7 +330,7 @@ bool QLinuxFbScreen::initialize(const QStringList &args) bool doSwitchToGraphicsMode = true; // Parse arguments - foreach (const QString &arg, args) { + foreach (const QString &arg, mArgs) { if (arg == QLatin1String("nographicsmodeswitch")) doSwitchToGraphicsMode = false; else if (sizeRx.indexIn(arg) != -1) diff --git a/src/plugins/platforms/linuxfb/qlinuxfbscreen.h b/src/plugins/platforms/linuxfb/qlinuxfbscreen.h index d34104c6e1..32cd263063 100644 --- a/src/plugins/platforms/linuxfb/qlinuxfbscreen.h +++ b/src/plugins/platforms/linuxfb/qlinuxfbscreen.h @@ -53,15 +53,16 @@ class QLinuxFbScreen : public QFbScreen { Q_OBJECT public: - QLinuxFbScreen(); + QLinuxFbScreen(const QStringList &args); ~QLinuxFbScreen(); - bool initialize(const QStringList &args); + bool initialize(); public slots: QRegion doRedraw(); private: + QStringList mArgs; int mFbFd; int mTtyFd; -- cgit v1.2.3