Crash: blocking JS and deleting a window
Koos Vriezen
koos.vriezen at xs4all.nl
Thu Oct 3 20:17:53 BST 2002
On Wed, 2 Oct 2002, Simon Hausmann wrote:
> > On Wed, 2 Oct 2002, Simon Hausmann wrote:
> > >
> > > We could do it like Qt does: Send a (custom) event to say the BE
> > > object and ask it to accept/ignore it (by letting the custom event
> > > class provide an accept/ingore API like many of the Qt events) . The
> > > default implementation could just acept it.
> > >
> > > Depending on the result Konq could accept/ignore the close event it
> > > receives.
Does the attached patch for kparts implements what you mean?
> I was thinking of immediate deletion.
Ah yes, sendEvent does that.
Koos
-------------- next part --------------
Index: browserextension.cpp
===================================================================
RCS file: /home/kde/kdelibs/kparts/browserextension.cpp,v
retrieving revision 1.40
diff -u -3 -p -r1.40 browserextension.cpp
--- browserextension.cpp 2002/08/18 11:17:54 1.40
+++ browserextension.cpp 2002/10/03 19:07:56
@@ -281,8 +281,14 @@ public:
}
};
-class BrowserExtensionPrivate
+BrowserExtensionEvent::BrowserExtensionEvent()
+ : QEvent(QEvent::Type((int)QEvent::User + can_delete_event)),
+ accepted( false )
{
+}
+
+class BrowserExtensionPrivate : public QObject
+{
public:
BrowserExtensionPrivate()
{
@@ -300,6 +306,15 @@ public:
bool m_urlDropHandlingEnabled;
KBitArray m_actionStatus;
BrowserInterface *m_browserInterface;
+protected:
+ bool eventFilter( QObject *, QEvent *e ) {
+ if ( (int)e->type() == (int)Event::User + (int)BrowserExtensionEvent::can_delete_event) {
+ ((BrowserExtensionEvent*)e)->accept();
+ // we can eat this event because where the last one to receive it
+ return TRUE;
+ }
+ return FALSE;
+ }
};
};
@@ -338,11 +353,13 @@ BrowserExtension::BrowserExtension( KPar
this, SLOT( slotOpenURLRequest( const KURL &, const KParts::URLArgs & ) ) );
connect( this, SIGNAL( enableAction( const char *, bool ) ),
this, SLOT( slotEnableAction( const char *, bool ) ) );
+ installEventFilter( d );
}
BrowserExtension::~BrowserExtension()
{
//kdDebug() << "BrowserExtension::~BrowserExtension() " << this << endl;
+ removeEventFilter( d );
delete d;
}
Index: browserextension.h
===================================================================
RCS file: /home/kde/kdelibs/kparts/browserextension.h,v
retrieving revision 1.94
diff -u -3 -p -r1.94 browserextension.h
--- browserextension.h 2002/08/18 11:17:54 1.94
+++ browserextension.h 2002/10/03 19:07:56
@@ -574,6 +574,21 @@ private:
BrowserExtensionPrivate *d;
};
+class BrowserExtensionEvent : public QEvent
+{
+public:
+ BrowserExtensionEvent();
+
+ bool isAccepted() const { return accepted; }
+ void accept() { accepted = true; }
+ void ignore() { accepted = false; }
+
+ enum BEEventType { can_delete_event = 0 };
+
+private:
+ bool accepted;
+};
+
/**
* An extension class for container parts, i.e. parts that contain
* other parts.
More information about the kfm-devel
mailing list