Bug 808358 - nsWindow.cpp:388:5: error: expected unqualified-id before if

This commit is contained in:
Oleg Romashin 2012-11-03 21:00:08 -07:00
Родитель 7864e2fd96
Коммит ab508f6753
3 изменённых файлов: 60 добавлений и 9 удалений

Просмотреть файл

@ -77,7 +77,8 @@ MozQWidget::~MozQWidget()
void MozQWidget::paint(QPainter* aPainter, const QStyleOptionGraphicsItem* aOption, QWidget* aWidget /*= 0*/) 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() void MozQWidget::activate()
@ -405,7 +406,9 @@ void MozQWidget::closeEvent(QCloseEvent* aEvent)
void MozQWidget::hideEvent(QHideEvent* aEvent) void MozQWidget::hideEvent(QHideEvent* aEvent)
{ {
mReceiver->hideEvent(aEvent); if (mReceiver) {
mReceiver->hideEvent(aEvent);
}
QGraphicsWidget::hideEvent(aEvent); QGraphicsWidget::hideEvent(aEvent);
} }

Просмотреть файл

@ -65,6 +65,7 @@ using namespace QtMobility;
#include "mozilla/Services.h" #include "mozilla/Services.h"
#include "mozilla/Preferences.h" #include "mozilla/Preferences.h"
#include "mozilla/Likely.h" #include "mozilla/Likely.h"
#include "LayersTypes.h"
#include "nsIWidgetListener.h" #include "nsIWidgetListener.h"
#include "nsIStringBundle.h" #include "nsIStringBundle.h"
@ -102,7 +103,9 @@ static Atom sPluginIMEAtom = nullptr;
#endif #endif
#endif //MOZ_X11 #endif //MOZ_X11
#include "gfxUtils.h"
#include "Layers.h" #include "Layers.h"
#include "GLContextProvider.h"
#include "BasicLayers.h" #include "BasicLayers.h"
#include "LayerManagerOGL.h" #include "LayerManagerOGL.h"
#include "nsFastStartupQt.h" #include "nsFastStartupQt.h"
@ -119,6 +122,8 @@ extern "C" {
using namespace mozilla; using namespace mozilla;
using namespace mozilla::widget; using namespace mozilla::widget;
using mozilla::gl::GLContext;
using mozilla::layers::LayerManagerOGL;
// Cached offscreen surface // Cached offscreen surface
static nsRefPtr<gfxASurface> gBufferSurface; static nsRefPtr<gfxASurface> gBufferSurface;
@ -379,16 +384,35 @@ nsWindow::Destroy(void)
#endif #endif
} }
/** Need to clean our LayerManager up while still alive */
if (mLayerManager) {
nsRefPtr<GLContext> gl = nullptr;
if (mLayerManager->GetBackendType() == mozilla::layers::LAYERS_OPENGL) {
LayerManagerOGL *ogllm = static_cast<LayerManagerOGL*>(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(); nsIRollupListener* rollupListener = nsBaseWidget::GetActiveRollupListener();
nsCOMPtr<nsIWidget> rollupWidget = rollupListener->GetRollupWidget(); nsCOMPtr<nsIWidget> rollupWidget = rollupListener->GetRollupWidget();
if (static_cast<nsIWidget *>(this) == rollupWidget) if (static_cast<nsIWidget *>(this) == rollupWidget)
rollupListener->Rollup(0, nullptr); rollupListener->Rollup(0, nullptr);
}
if (mLayerManager) {
mLayerManager->Destroy();
}
mLayerManager = nullptr;
Show(false); Show(false);
@ -431,6 +455,21 @@ nsWindow::Destroy(void)
return NS_OK; return NS_OK;
} }
void
nsWindow::ClearCachedResources()
{
if (mLayerManager &&
mLayerManager->GetBackendType() == mozilla::layers::LAYERS_BASIC) {
static_cast<mozilla::layers::BasicLayerManager*> (mLayerManager.get())->
ClearCachedResources();
}
for (nsIWidget* kid = mFirstChild; kid; ) {
nsIWidget* next = kid->GetNextSibling();
static_cast<nsWindow*>(kid)->ClearCachedResources();
kid = next;
}
}
NS_IMETHODIMP NS_IMETHODIMP
nsWindow::SetParent(nsIWidget *aNewParent) nsWindow::SetParent(nsIWidget *aNewParent)
{ {
@ -1659,7 +1698,7 @@ nsWindow::OnKeyPressEvent(QKeyEvent *aEvent)
KeySym keysym = aEvent->nativeVirtualKey(); KeySym keysym = aEvent->nativeVirtualKey();
if (keysym) { if (keysym) {
domCharCode = (uint32_t) keysym2ucs(keysym); domCharCode = (uint32_t) keysym2ucs(keysym);
if (domCharCode == -1 || ! QChar((quint32)domCharCode).isPrint()) { if (domCharCode == -1 || !QChar((quint32)domCharCode).isPrint()) {
domCharCode = 0; domCharCode = 0;
} }
} }
@ -2609,6 +2648,7 @@ nsWindow::createQWidget(MozQWidget *parent,
MozQWidget * widget = new MozQWidget(this, parentQWidget); MozQWidget * widget = new MozQWidget(this, parentQWidget);
if (!widget) if (!widget)
return nullptr; return nullptr;
widget->setObjectName(QString(windowName));
// make only child and plugin windows focusable // make only child and plugin windows focusable
if (eWindowType_child == mWindowType || eWindowType_plugin == mWindowType) { if (eWindowType_child == mWindowType || eWindowType_plugin == mWindowType) {
@ -2857,6 +2897,13 @@ NS_IMETHODIMP
nsWindow::Show(bool aState) nsWindow::Show(bool aState)
{ {
LOG(("nsWindow::Show [%p] state %d\n", (void *)this, 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; mIsShown = aState;

Просмотреть файл

@ -316,6 +316,7 @@ private:
nsNativeWidget nativeParent, nsNativeWidget nativeParent,
nsWidgetInitData* aInitData); nsWidgetInitData* aInitData);
void SetSoftwareKeyboardState(bool aOpen, const InputContextAction& aAction); void SetSoftwareKeyboardState(bool aOpen, const InputContextAction& aAction);
void ClearCachedResources();
MozQWidget* mWidget; MozQWidget* mWidget;