Check for deletion while handling mouse release on the close button.

Fixes #67267.

svn path=/trunk/kdebase/kwin/; revision=268388
This commit is contained in:
Luboš Luňák 2003-11-20 13:31:19 +00:00
parent b7e040b873
commit d1cd1a1b18
15 changed files with 34 additions and 28 deletions

View file

@ -366,39 +366,39 @@ WebClient::_createButton(const QString & s, QWidget * parent)
if (("Help" == s) && providesContextHelp())
{
b = new WebButtonHelp(parent);
b = new WebButtonHelp(parent, this);
connect(b, SIGNAL(help()), this, SLOT(showContextHelp()));
}
else if ("OnAllDesktops" == s)
{
b = new WebButtonSticky(isOnAllDesktops(), parent);
b = new WebButtonSticky(isOnAllDesktops(), parent, this);
connect(b, SIGNAL(toggleSticky()), this, SLOT(toggleOnAllDesktops()));
connect(this, SIGNAL(oadChange(bool)), b, SLOT(slotOnAllDesktopsChange(bool)));
}
else if ("Minimize" == s && isMinimizable())
{
b = new WebButtonIconify(parent);
b = new WebButtonIconify(parent, this);
connect(b, SIGNAL(minimize()), this, SLOT(minimize()));
}
else if ("Maximize" == s && isMaximizable())
{
b = new WebButtonMaximize((maximizeMode()==MaximizeFull), parent);
b = new WebButtonMaximize((maximizeMode()==MaximizeFull), parent, this);
connect(b, SIGNAL(maximize(int)), this, SLOT(slotMaximize(int)));
connect(this, SIGNAL(maxChange(bool)), b, SLOT(slotMaximizeChange(bool)));
}
else if ("Close" == s && isCloseable())
{
b = new WebButtonClose(parent);
b = new WebButtonClose(parent, this);
connect(b, SIGNAL(closeWindow()), this, SLOT(closeWindow()));
}
else if ("Lower" == s)
{
b = new WebButtonLower(parent);
b = new WebButtonLower(parent, this);
connect(b, SIGNAL(lowerWindow()), this, SLOT(slotLowerWindow()));
}

View file

@ -23,18 +23,19 @@
#include <qpainter.h>
#include <qtooltip.h>
#include <qapplication.h>
#include "../../lib/kdecoration.h"
#include "WebButton.h"
#include "Web.h"
namespace Web {
WebButton::WebButton(QWidget * parent, const QString& tip)
WebButton::WebButton(QWidget * parent, const QString& tip, WebClient* deco)
: QButton (parent, 0, 0),
mouseOver_ (false),
mouseDown_ (false),
position_ (Mid),
shape_ (false)
shape_ (false),
deco_ (deco)
{
setTipText(tip);
setCursor(ArrowCursor);
@ -68,10 +69,13 @@ WebButton::mouseReleaseEvent(QMouseEvent * e)
mouseDown_ = false;
repaint();
KDecorationFactory* f = deco_->factory();
if (rect().contains(e->pos()))
{
clickEvent(e->button());
}
if( !f->exists( deco_ )) // decoration was destroyed
return;
QButton::mouseReleaseEvent(e);
}

View file

@ -29,6 +29,7 @@
namespace Web
{
class WebClient;
class WebButton : public QButton
{
@ -41,7 +42,7 @@ namespace Web
Left, Mid, Right
};
WebButton(QWidget * parent, const QString& tip);
WebButton(QWidget * parent, const QString& tip, WebClient* deco);
virtual ~WebButton();
@ -77,6 +78,7 @@ namespace Web
Position position_;
bool shape_;
WebClient* deco_;
};
}

View file

@ -28,8 +28,8 @@ static unsigned char close_bits[] =
0x42, 0xe7, 0x7e, 0x3c, 0x3c, 0x7e, 0xe7, 0x42
};
WebButtonClose::WebButtonClose(QWidget * parent)
: WebButton(parent, i18n("Close"))
WebButtonClose::WebButtonClose(QWidget * parent, WebClient* deco)
: WebButton(parent, i18n("Close"), deco)
{
QBitmap b(8, 8, close_bits, true /* isXBitmap */);
b.setMask(b);

View file

@ -33,7 +33,7 @@ namespace Web
public:
WebButtonClose(QWidget * parent);
WebButtonClose(QWidget * parent, WebClient* deco);
protected:

View file

@ -29,8 +29,8 @@ static unsigned char help_bits[] =
0x18, 0x18, 0x00, 0x1c, 0x18, 0x18, 0x18, 0x3c
};
WebButtonHelp::WebButtonHelp(QWidget * parent)
: WebButton(parent, i18n("Help"))
WebButtonHelp::WebButtonHelp(QWidget * parent, WebClient* deco)
: WebButton(parent, i18n("Help"), deco)
{
QBitmap b(8, 8, help_bits, true /* isXBitmap */);
b.setMask(b);

View file

@ -33,7 +33,7 @@ namespace Web
public:
WebButtonHelp(QWidget * parent);
WebButtonHelp(QWidget * parent, WebClient* deco);
protected:

View file

@ -28,8 +28,8 @@ static unsigned char iconify_bits[] =
0x00, 0x00, 0x00, 0x7e, 0x7e, 0x3c, 0x18, 0x00
};
WebButtonIconify::WebButtonIconify(QWidget * parent)
: WebButton(parent, i18n("Minimize"))
WebButtonIconify::WebButtonIconify(QWidget * parent, WebClient* deco)
: WebButton(parent, i18n("Minimize"), deco)
{
QBitmap b(8, 8, iconify_bits, true /* isXBitmap */);
b.setMask(b);

View file

@ -33,7 +33,7 @@ namespace Web
public:
WebButtonIconify(QWidget * parent);
WebButtonIconify(QWidget * parent, WebClient* deco);
protected:

View file

@ -28,8 +28,8 @@ static unsigned char lower_bits[] =
0x1f, 0x1f, 0x1f, 0xff, 0x8f, 0x88, 0x88, 0xf8
};
WebButtonLower::WebButtonLower(QWidget * parent)
: WebButton(parent, i18n("Lower"))
WebButtonLower::WebButtonLower(QWidget * parent, WebClient* deco)
: WebButton(parent, i18n("Lower"), deco)
{
QBitmap b(8, 8, lower_bits, true /* isXBitmap */);
b.setMask(b);

View file

@ -33,7 +33,7 @@ namespace Web
public:
WebButtonLower(QWidget * parent);
WebButtonLower(QWidget * parent, WebClient* deco);
protected:

View file

@ -33,8 +33,8 @@ static unsigned char unmaximize_bits[] =
0x00, 0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f
};
WebButtonMaximize::WebButtonMaximize(bool max, QWidget * parent)
: WebButton(parent, i18n("Maximize"))
WebButtonMaximize::WebButtonMaximize(bool max, QWidget * parent, WebClient* deco)
: WebButton(parent, i18n("Maximize"), deco)
{
QBitmap b(8, 8, max ? unmaximize_bits : maximize_bits, true /* isXBitmap */);
b.setMask(b);

View file

@ -33,7 +33,7 @@ namespace Web
public:
WebButtonMaximize(bool maximised, QWidget * parent);
WebButtonMaximize(bool maximised, QWidget * parent, WebClient* deco);
protected:

View file

@ -33,8 +33,8 @@ static unsigned char unsticky_bits[] =
0x1c, 0x1c, 0x1c, 0x3e, 0x7f, 0x08, 0x08, 0x08
};
WebButtonSticky::WebButtonSticky(bool sticky, QWidget * parent)
: WebButton(parent, i18n("On All Desktops"))
WebButtonSticky::WebButtonSticky(bool sticky, QWidget * parent, WebClient* deco)
: WebButton(parent, i18n("On All Desktops"), deco)
{
QBitmap b(8, 8, sticky ? unsticky_bits : sticky_bits, true /* isXBitmap */);
b.setMask(b);

View file

@ -33,7 +33,7 @@ namespace Web
public:
WebButtonSticky(bool sticky, QWidget * parent);
WebButtonSticky(bool sticky, QWidget * parent, WebClient* deco);
protected: