From ab508f6753a62fa014cf993f9f2e5323efa942cf Mon Sep 17 00:00:00 2001 From: Oleg Romashin Date: Sat, 3 Nov 2012 21:00:08 -0700 Subject: [PATCH] Bug 808358 - nsWindow.cpp:388:5: error: expected unqualified-id before if --- widget/qt/mozqwidget.cpp | 7 +++-- widget/qt/nsWindow.cpp | 61 +++++++++++++++++++++++++++++++++++----- widget/qt/nsWindow.h | 1 + 3 files changed, 60 insertions(+), 9 deletions(-) diff --git a/widget/qt/mozqwidget.cpp b/widget/qt/mozqwidget.cpp index 268e4e8d0ef7..d8e7a6b7e115 100644 --- a/widget/qt/mozqwidget.cpp +++ b/widget/qt/mozqwidget.cpp @@ -77,7 +77,8 @@ MozQWidget::~MozQWidget() void MozQWidget::paint(QPainter* aPainter, const QStyleOptionGraphicsItem* aOption, QWidget* aWidget /*= 0*/) { - mReceiver->DoPaint(aPainter, aOption, aWidget); + if (mReceiver) + mReceiver->DoPaint(aPainter, aOption, aWidget); } void MozQWidget::activate() @@ -405,7 +406,9 @@ void MozQWidget::closeEvent(QCloseEvent* aEvent) void MozQWidget::hideEvent(QHideEvent* aEvent) { - mReceiver->hideEvent(aEvent); + if (mReceiver) { + mReceiver->hideEvent(aEvent); + } QGraphicsWidget::hideEvent(aEvent); } diff --git a/widget/qt/nsWindow.cpp b/widget/qt/nsWindow.cpp index 0bf6e924a889..ff7e3d188d34 100644 --- a/widget/qt/nsWindow.cpp +++ b/widget/qt/nsWindow.cpp @@ -65,6 +65,7 @@ using namespace QtMobility; #include "mozilla/Services.h" #include "mozilla/Preferences.h" #include "mozilla/Likely.h" +#include "LayersTypes.h" #include "nsIWidgetListener.h" #include "nsIStringBundle.h" @@ -102,7 +103,9 @@ static Atom sPluginIMEAtom = nullptr; #endif #endif //MOZ_X11 +#include "gfxUtils.h" #include "Layers.h" +#include "GLContextProvider.h" #include "BasicLayers.h" #include "LayerManagerOGL.h" #include "nsFastStartupQt.h" @@ -119,6 +122,8 @@ extern "C" { using namespace mozilla; using namespace mozilla::widget; +using mozilla::gl::GLContext; +using mozilla::layers::LayerManagerOGL; // Cached offscreen surface static nsRefPtr gBufferSurface; @@ -379,16 +384,35 @@ nsWindow::Destroy(void) #endif } + /** Need to clean our LayerManager up while still alive */ + if (mLayerManager) { + nsRefPtr gl = nullptr; + if (mLayerManager->GetBackendType() == mozilla::layers::LAYERS_OPENGL) { + LayerManagerOGL *ogllm = static_cast(mLayerManager.get()); + gl = ogllm->gl(); + } + + mLayerManager->Destroy(); + + if (gl) { + gl->MarkDestroyed(); + } + } + mLayerManager = nullptr; + + // It is safe to call DestroyeCompositor several times (here and + // in the parent class) since it will take effect only once. + // The reason we call it here is because on gtk platforms we need + // to destroy the compositor before we destroy the gdk window (which + // destroys the the gl context attached to it). + DestroyCompositor(); + + ClearCachedResources(); + nsIRollupListener* rollupListener = nsBaseWidget::GetActiveRollupListener(); nsCOMPtr rollupWidget = rollupListener->GetRollupWidget(); if (static_cast(this) == rollupWidget) rollupListener->Rollup(0, nullptr); - } - - if (mLayerManager) { - mLayerManager->Destroy(); - } - mLayerManager = nullptr; Show(false); @@ -431,6 +455,21 @@ nsWindow::Destroy(void) return NS_OK; } +void +nsWindow::ClearCachedResources() +{ + if (mLayerManager && + mLayerManager->GetBackendType() == mozilla::layers::LAYERS_BASIC) { + static_cast (mLayerManager.get())-> + ClearCachedResources(); + } + for (nsIWidget* kid = mFirstChild; kid; ) { + nsIWidget* next = kid->GetNextSibling(); + static_cast(kid)->ClearCachedResources(); + kid = next; + } +} + NS_IMETHODIMP nsWindow::SetParent(nsIWidget *aNewParent) { @@ -1659,7 +1698,7 @@ nsWindow::OnKeyPressEvent(QKeyEvent *aEvent) KeySym keysym = aEvent->nativeVirtualKey(); if (keysym) { domCharCode = (uint32_t) keysym2ucs(keysym); - if (domCharCode == -1 || ! QChar((quint32)domCharCode).isPrint()) { + if (domCharCode == -1 || !QChar((quint32)domCharCode).isPrint()) { domCharCode = 0; } } @@ -2609,6 +2648,7 @@ nsWindow::createQWidget(MozQWidget *parent, MozQWidget * widget = new MozQWidget(this, parentQWidget); if (!widget) return nullptr; + widget->setObjectName(QString(windowName)); // make only child and plugin windows focusable if (eWindowType_child == mWindowType || eWindowType_plugin == mWindowType) { @@ -2857,6 +2897,13 @@ NS_IMETHODIMP nsWindow::Show(bool aState) { LOG(("nsWindow::Show [%p] state %d\n", (void *)this, aState)); + if (aState == mIsShown) + return NS_OK; + + // Clear our cached resources when the window is hidden. + if (mIsShown && !aState) { + ClearCachedResources(); + } mIsShown = aState; diff --git a/widget/qt/nsWindow.h b/widget/qt/nsWindow.h index 188171de7171..f8d0b3ef395d 100644 --- a/widget/qt/nsWindow.h +++ b/widget/qt/nsWindow.h @@ -316,6 +316,7 @@ private: nsNativeWidget nativeParent, nsWidgetInitData* aInitData); void SetSoftwareKeyboardState(bool aOpen, const InputContextAction& aAction); + void ClearCachedResources(); MozQWidget* mWidget;