Bug 485579. Fix possible crash when closing tabs using cairo-qt. r=vlad, a=beltzner
--- a/widget/src/qt/mozqwidget.cpp
+++ b/widget/src/qt/mozqwidget.cpp
@@ -5,16 +5,22 @@
MozQWidget::MozQWidget(nsWindow *receiver, QWidget *parent,
const char *name, int f)
: QWidget(parent, (Qt::WindowFlags)f),
mReceiver(receiver)
{
setAttribute(Qt::WA_QuitOnClose, false);
}
+MozQWidget::~MozQWidget()
+{
+ if (mReceiver)
+ mReceiver->QWidgetDestroyed();
+}
+
bool MozQWidget::event(QEvent *e)
{
nsEventStatus status = nsEventStatus_eIgnore;
bool handled = true;
// always handle (delayed) delete requests triggered by
// calling deleteLater() on this widget:
if (e->type() == QEvent::DeferredDelete)
--- a/widget/src/qt/mozqwidget.h
+++ b/widget/src/qt/mozqwidget.h
@@ -9,16 +9,18 @@ class nsWindow;
class MozQWidget : public QWidget
{
Q_OBJECT
public:
MozQWidget(nsWindow* receiver, QWidget *parent,
const char *name, int f);
+ ~MozQWidget();
+
/**
* Mozilla helper.
*/
void setModal(bool);
bool SetCursor(nsCursor aCursor);
void dropReceiver() { mReceiver = 0x0; };
nsWindow* getReceiver() { return mReceiver; };
--- a/widget/src/qt/nsWindow.cpp
+++ b/widget/src/qt/nsWindow.cpp
@@ -104,16 +104,18 @@
#include <qobject.h>
#include <execinfo.h>
#include <stdlib.h>
#ifdef Q_WS_X11
#include "qx11info_x11.h"
#endif
+#include <QtCore/QDebug>
+
#include <execinfo.h>
#include "mozqwidget.h"
/* For PrepareNativeWidget */
static NS_DEFINE_IID(kDeviceContextCID, NS_DEVICE_CONTEXT_CID);
// initialization static functions
@@ -311,16 +313,17 @@ nsWindow::Destroy(void)
mMozQWidget->dropReceiver();
// Call deleteLater instead of delete; Qt still needs the object
// to be valid even after sending it a Close event. We could
// also set WA_DeleteOnClose, but this gives us more control.
mMozQWidget->deleteLater();
}
+ mMozQWidget = nsnull;
mDrawingArea = nsnull;
OnDestroy();
return NS_OK;
}
NS_IMETHODIMP
@@ -1963,16 +1966,22 @@ nsWindow::ConvertBorderStyles(nsBorderSt
#ifdef DEBUG
printf("we don't handle eBorderStyle_close yet... please fix me\n");
#endif
}
*/
return w;
}
+void nsWindow::QWidgetDestroyed()
+{
+ mDrawingArea = nsnull;
+ mMozQWidget = nsnull;
+}
+
NS_IMETHODIMP
nsWindow::MakeFullScreen(PRBool aFullScreen)
{
/*
#if GTK_CHECK_VERSION(2,2,0)
if (aFullScreen)
gdk_window_fullscreen (mDrawingArea->window);
else
--- a/widget/src/qt/nsWindow.h
+++ b/widget/src/qt/nsWindow.h
@@ -203,16 +203,18 @@ public:
//
// utility methods
//
void LoseFocus();
qint32 ConvertBorderStyles(nsBorderStyle aStyle);
+ void QWidgetDestroyed();
+
/***** from CommonWidget *****/
// event handling code
void DispatchGotFocusEvent(void);
void DispatchLostFocusEvent(void);
void DispatchActivateEvent(void);