Crash in khtml::ComboBoxWidget selection event

Koos Vriezen koos.vriezen at xs4all.nl
Sun Aug 11 19:17:04 BST 2002


On Sat, 10 Aug 2002, Koos Vriezen wrote:

>   <HTML><HEAD><SCRIPT>
>     function selected(option) {
>       loaded();
>     }
>     function loaded() {
>       myframe.document.open();
>       myframe.document.write("<html><body><form><select onChange=
>         'javascript:top.selected(this.options[this.selectedIndex].text)'>
>         <option selected>one</option><option>two</option>
>         <option>three</option></select></form></body></html>");
>       myframe.document.close();
>     }
>   </SCRIPT> </HEAD>
>   <FRAMESET onLoad="loaded()">
>     <FRAME NAME="myframe" SRC="about:blank">
>   </FRAMESET></HTML>
>
> (Don't forget to join the myframe.document.write line)

Obviously QComboBox don't like to be deleted while emit'ing a signal.
Attached a patch which loosens khtml event chain from the QComboBox signal
chain by using a single shot timer.
Shouldn't this be for all form element generated signals that can
trigger a JS event?

Regards,

Koos
-------------- next part --------------
Index: rendering/render_form.cpp
===================================================================
RCS file: /home/kde/kdelibs/khtml/rendering/render_form.cpp,v
retrieving revision 1.186
diff -u -3 -p -r1.186 render_form.cpp
--- rendering/render_form.cpp	2002/08/10 08:43:17	1.186
+++ rendering/render_form.cpp	2002/08/11 18:16:51
@@ -30,6 +30,7 @@
 #include <kcursor.h>
 
 #include <qstyle.h>
+#include <qtimer.h>
 
 #include "misc/helper.h"
 #include "xml/dom2_eventsimpl.h"
@@ -1091,11 +1092,14 @@ void RenderSelect::slotSelected(int inde
             static_cast<HTMLOptionElementImpl*>(listItems[index])->m_selected = true;
         }
     }
+    QTimer::singleShot(0, this, SLOT(slotTimerSelectionChanged()));
+}
 
+void RenderSelect::slotTimerSelectionChanged()
+{
     element()->onChange();
 }
 
-
 void RenderSelect::slotSelectionChanged()
 {
     if ( m_ignoreSelectEvents ) return;
@@ -1110,7 +1114,7 @@ void RenderSelect::slotSelectionChanged(
             static_cast<HTMLOptionElementImpl*>( listItems[i] )
                 ->m_selected = static_cast<KListBox*>( m_widget )->isSelected( i );
 
-    element()->onChange();
+    QTimer::singleShot(0, this, SLOT(slotTimerSelectionChanged()));
 }
 
 
Index: rendering/render_form.h
===================================================================
RCS file: /home/kde/kdelibs/khtml/rendering/render_form.h,v
retrieving revision 1.74
diff -u -3 -p -r1.74 render_form.h
--- rendering/render_form.h	2002/08/09 15:15:26	1.74
+++ rendering/render_form.h	2002/08/11 18:16:52
@@ -376,6 +376,7 @@ protected:
 protected slots:
     void slotSelected(int index);
     void slotSelectionChanged();
+    void slotTimerSelectionChanged();
 };
 
 // -------------------------------------------------------------------------


More information about the kfm-devel mailing list