From d1cd1a1b1890e55b12d8adf082fe5261dc01a1d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubo=C5=A1=20Lu=C5=88=C3=A1k?= Date: Thu, 20 Nov 2003 13:31:19 +0000 Subject: [PATCH] Check for deletion while handling mouse release on the close button. Fixes #67267. svn path=/trunk/kdebase/kwin/; revision=268388 --- clients/web/Web.cpp | 12 ++++++------ clients/web/WebButton.cpp | 10 +++++++--- clients/web/WebButton.h | 4 +++- clients/web/WebButtonClose.cpp | 4 ++-- clients/web/WebButtonClose.h | 2 +- clients/web/WebButtonHelp.cpp | 4 ++-- clients/web/WebButtonHelp.h | 2 +- clients/web/WebButtonIconify.cpp | 4 ++-- clients/web/WebButtonIconify.h | 2 +- clients/web/WebButtonLower.cpp | 4 ++-- clients/web/WebButtonLower.h | 2 +- clients/web/WebButtonMaximize.cpp | 4 ++-- clients/web/WebButtonMaximize.h | 2 +- clients/web/WebButtonSticky.cpp | 4 ++-- clients/web/WebButtonSticky.h | 2 +- 15 files changed, 34 insertions(+), 28 deletions(-) diff --git a/clients/web/Web.cpp b/clients/web/Web.cpp index df513e842c..ed04867c73 100644 --- a/clients/web/Web.cpp +++ b/clients/web/Web.cpp @@ -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())); } diff --git a/clients/web/WebButton.cpp b/clients/web/WebButton.cpp index a644648692..372b351096 100644 --- a/clients/web/WebButton.cpp +++ b/clients/web/WebButton.cpp @@ -23,18 +23,19 @@ #include #include #include -#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); } diff --git a/clients/web/WebButton.h b/clients/web/WebButton.h index 8d62cc9aca..af24778e6d 100644 --- a/clients/web/WebButton.h +++ b/clients/web/WebButton.h @@ -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_; }; } diff --git a/clients/web/WebButtonClose.cpp b/clients/web/WebButtonClose.cpp index e6373a2527..07f41051eb 100644 --- a/clients/web/WebButtonClose.cpp +++ b/clients/web/WebButtonClose.cpp @@ -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); diff --git a/clients/web/WebButtonClose.h b/clients/web/WebButtonClose.h index 62ea4b2a0a..385c49173f 100644 --- a/clients/web/WebButtonClose.h +++ b/clients/web/WebButtonClose.h @@ -33,7 +33,7 @@ namespace Web public: - WebButtonClose(QWidget * parent); + WebButtonClose(QWidget * parent, WebClient* deco); protected: diff --git a/clients/web/WebButtonHelp.cpp b/clients/web/WebButtonHelp.cpp index b581fd7c51..cad28bbb3b 100644 --- a/clients/web/WebButtonHelp.cpp +++ b/clients/web/WebButtonHelp.cpp @@ -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); diff --git a/clients/web/WebButtonHelp.h b/clients/web/WebButtonHelp.h index 689e2499e5..74acc8f734 100644 --- a/clients/web/WebButtonHelp.h +++ b/clients/web/WebButtonHelp.h @@ -33,7 +33,7 @@ namespace Web public: - WebButtonHelp(QWidget * parent); + WebButtonHelp(QWidget * parent, WebClient* deco); protected: diff --git a/clients/web/WebButtonIconify.cpp b/clients/web/WebButtonIconify.cpp index 09a713bfe3..62d7d64b0f 100644 --- a/clients/web/WebButtonIconify.cpp +++ b/clients/web/WebButtonIconify.cpp @@ -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); diff --git a/clients/web/WebButtonIconify.h b/clients/web/WebButtonIconify.h index 7503115dd9..22334ac0c4 100644 --- a/clients/web/WebButtonIconify.h +++ b/clients/web/WebButtonIconify.h @@ -33,7 +33,7 @@ namespace Web public: - WebButtonIconify(QWidget * parent); + WebButtonIconify(QWidget * parent, WebClient* deco); protected: diff --git a/clients/web/WebButtonLower.cpp b/clients/web/WebButtonLower.cpp index 352057493c..ec488a23b8 100644 --- a/clients/web/WebButtonLower.cpp +++ b/clients/web/WebButtonLower.cpp @@ -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); diff --git a/clients/web/WebButtonLower.h b/clients/web/WebButtonLower.h index 41dddc7044..9adc7d1d6f 100644 --- a/clients/web/WebButtonLower.h +++ b/clients/web/WebButtonLower.h @@ -33,7 +33,7 @@ namespace Web public: - WebButtonLower(QWidget * parent); + WebButtonLower(QWidget * parent, WebClient* deco); protected: diff --git a/clients/web/WebButtonMaximize.cpp b/clients/web/WebButtonMaximize.cpp index 4b9bd9332a..ebe2bc0433 100644 --- a/clients/web/WebButtonMaximize.cpp +++ b/clients/web/WebButtonMaximize.cpp @@ -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); diff --git a/clients/web/WebButtonMaximize.h b/clients/web/WebButtonMaximize.h index 93733432f4..d840669646 100644 --- a/clients/web/WebButtonMaximize.h +++ b/clients/web/WebButtonMaximize.h @@ -33,7 +33,7 @@ namespace Web public: - WebButtonMaximize(bool maximised, QWidget * parent); + WebButtonMaximize(bool maximised, QWidget * parent, WebClient* deco); protected: diff --git a/clients/web/WebButtonSticky.cpp b/clients/web/WebButtonSticky.cpp index ba50ea6b2e..69db003878 100644 --- a/clients/web/WebButtonSticky.cpp +++ b/clients/web/WebButtonSticky.cpp @@ -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); diff --git a/clients/web/WebButtonSticky.h b/clients/web/WebButtonSticky.h index 213082d027..fb27acf2ab 100644 --- a/clients/web/WebButtonSticky.h +++ b/clients/web/WebButtonSticky.h @@ -33,7 +33,7 @@ namespace Web public: - WebButtonSticky(bool sticky, QWidget * parent); + WebButtonSticky(bool sticky, QWidget * parent, WebClient* deco); protected: