Android: Fix crash when using QBackingStore
When making a QBackingStore for a QWindow that was not created yet, Qt would try to dereference the (null) platform window pointer. Task-number: QTBUG-31022 Change-Id: I866c71cce9d401ebb598ea4cc91f7cf9bbb30982 Reviewed-by: Samuel Rødal <samuel.rodal@digia.com> Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
This commit is contained in:
parent
18db71d601
commit
3c50917a6a
@ -51,7 +51,10 @@ QT_BEGIN_NAMESPACE
|
||||
QFbBackingStore::QFbBackingStore(QWindow *window)
|
||||
: QPlatformBackingStore(window)
|
||||
{
|
||||
(static_cast<QFbWindow *>(window->handle()))->setBackingStore(this);
|
||||
if (window->handle())
|
||||
(static_cast<QFbWindow *>(window->handle()))->setBackingStore(this);
|
||||
else
|
||||
(static_cast<QFbScreen *>(window->screen()->handle()))->addBackingStore(this);
|
||||
}
|
||||
|
||||
QFbBackingStore::~QFbBackingStore()
|
||||
|
@ -71,6 +71,19 @@ void QFbScreen::initializeCompositor()
|
||||
void QFbScreen::addWindow(QFbWindow *window)
|
||||
{
|
||||
mWindowStack.prepend(window);
|
||||
if (!mBackingStores.isEmpty()) {
|
||||
//check if we have a backing store for this window
|
||||
for (int i = 0; i < mBackingStores.size(); ++i) {
|
||||
QFbBackingStore *bs = mBackingStores.at(i);
|
||||
// this gets called during QWindow::create() at a point where the
|
||||
// invariant (window->handle()->window() == window) is broken
|
||||
if (bs->window() == window->window()) {
|
||||
window->setBackingStore(bs);
|
||||
mBackingStores.removeAt(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
invalidateRectCache();
|
||||
setDirty(window->geometry());
|
||||
QWindow *w = topWindow();
|
||||
|
@ -51,6 +51,7 @@ QT_BEGIN_NAMESPACE
|
||||
class QFbWindow;
|
||||
class QFbCursor;
|
||||
class QPainter;
|
||||
class QFbBackingStore;
|
||||
|
||||
class QFbScreen : public QObject, public QPlatformScreen
|
||||
{
|
||||
@ -74,6 +75,8 @@ public:
|
||||
virtual void lower(QFbWindow *window);
|
||||
virtual void topWindowChanged(QWindow *) {}
|
||||
|
||||
void addBackingStore(QFbBackingStore *bs) {mBackingStores << bs;}
|
||||
|
||||
public slots:
|
||||
virtual void setDirty(const QRect &rect);
|
||||
void setPhysicalSize(const QSize &size);
|
||||
@ -102,6 +105,7 @@ private:
|
||||
|
||||
QPainter *mCompositePainter;
|
||||
QList<QPair<QRect, int> > mCachedRects;
|
||||
QList <QFbBackingStore*> mBackingStores;
|
||||
|
||||
friend class QFbWindow;
|
||||
bool mIsUpToDate;
|
||||
|
Loading…
Reference in New Issue
Block a user