Bug 49896 - [SHOWSTOPPER] konqueror crashes when launching embedded viewer from context menu
Summary: [SHOWSTOPPER] konqueror crashes when launching embedded viewer from context menu
Status: RESOLVED FIXED
Alias: None
Product: kdelibs
Classification: Unmaintained
Component: qt (show other bugs)
Version: SVN
Platform: Compiled Sources Linux
: NOR grave
Target Milestone: ---
Assignee: kdelibs bugs
URL:
Keywords:
: 49600 49956 (view as bug list)
Depends on:
Blocks:
 
Reported: 2002-10-29 23:03 UTC by Oliver Bausinger
Modified: 2007-11-07 18:57 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
test-3.cc (733 bytes, text/plain)
2002-10-30 12:45 UTC, Simon Hausmann
Details
test-1.h (267 bytes, text/plain)
2002-10-30 12:45 UTC, Simon Hausmann
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Oliver Bausinger 2002-10-29 23:03:42 UTC
Version:            (using KDE Devel)
Installed from:    Compiled sources
Compiler:          gcc 2.95.4  (Debian Sid)
OS:          Linux

This is a reliable way to crash Konqi. kdelibs, kdebase, qt-copy from  October 27-28:

Text File -> Right Click -> Preview In -> Embedded Advanced Text Editor
Konqueror crashes with the attached backtrace.

Please note: 
1) This is viewer-specific. I can get this with embedding kghostview, embedding komparepart, and others
2) This does not happen when I click directly on the file (without using the context menu). The appropriate viewer works correctly. So it's some interaction with the context menu.

I'm not sure but I think I first saw this when switching to qt-copy 3.1 snapshots. So it might be a QT bug.

The backtrace:
[New Thread 16384 (LWP 714)]
0x4117f2e9 in wait4 () from /lib/libc.so.6
#0  0x4117f2e9 in wait4 () from /lib/libc.so.6
#1  0x411f1704 in sys_sigabbrev () from /lib/libc.so.6
#2  0x41014c84 in waitpid () from /lib/libpthread.so.0
#3  0x407ec873 in KCrash::defaultCrashHandler (sig=11)
    at ../../../kdelibs/kdecore/kcrash.cpp:235
#4  0x4110ab88 in sigaction () from /lib/libc.so.6
#5  0x4012e81a in KonqIconViewWidget::contentsMousePressEvent (this=0x81d3630, 
    e=0xbfffef10) at ../../../kdebase/libkonq/konq_iconviewwidget.cc:1271
#6  0x40c1eb07 in QScrollView::viewportMousePressEvent ()
   from /usr/lib/libqt-mt.so.3
#7  0x40c1e4bb in QScrollView::eventFilter () from /usr/lib/libqt-mt.so.3
#8  0x40ca93ae in QIconView::eventFilter () from /usr/lib/libqt-mt.so.3
#9  0x40b4a540 in QObject::activate_filters () from /usr/lib/libqt-mt.so.3
#10 0x40b4a421 in QObject::event () from /usr/lib/libqt-mt.so.3
#11 0x40b76a79 in QWidget::event () from /usr/lib/libqt-mt.so.3
#12 0x40afa5a3 in QApplication::internalNotify () from /usr/lib/libqt-mt.so.3
#13 0x40afa08b in QApplication::notify () from /usr/lib/libqt-mt.so.3
#14 0x40771ce0 in KApplication::notify (this=0xbffff740, receiver=0x81d3ec0, 
    event=0xbffff27c) at ../../../kdelibs/kdecore/kapplication.cpp:441
#15 0x40ab018a in QETWidget::translateMouseEvent () from /usr/lib/libqt-mt.so.3
#16 0x40aae428 in QApplication::x11ProcessEvent () from /usr/lib/libqt-mt.so.3
#17 0x40abf450 in QEventLoop::processEvents () from /usr/lib/libqt-mt.so.3
#18 0x40b0bb75 in QEventLoop::enterLoop () from /usr/lib/libqt-mt.so.3
#19 0x40b0baef in QEventLoop::exec () from /usr/lib/libqt-mt.so.3
#20 0x40afa6fa in QApplication::exec () from /usr/lib/libqt-mt.so.3
#21 0x40060b24 in main (argc=1, argv=0xbffff874)
    at ../../../kdebase/konqueror/konq_main.cc:130
Comment 1 Oliver Bausinger 2002-10-30 08:25:04 UTC
Of course, (1) should be: this is _not_ viewer-specific.  -- OB 
Comment 2 Simon Hausmann 2002-10-30 12:45:02 UTC
Subject: serious eventloop regression

Hi Trolls,

(qt-3.1rc1)

The attached testcase shows that a null single-shot timer started
from a slot connected to a popup menu item will get fired before the
event loop of the menu is left.

Quite some code in KDE relies on this behaviour, allowing to execute
slots 'outside' of the local event loop. Like for example when a
popup menu is executed from within an iconview's mouse event
handler, providing an action that causes the iconview to get deleted
and replace with another view. KDE in that case uses a single-shot
timer to really perform the destructive action when the popup menu
is closed and we're back in the previous/global event loop. The SST
in that case is started from within the slot connected to the
activated() signal of the menu (item) , just like in the testcase.

The testcase works (as in never shows the 'timeout' debug output)
with Qt 2.3.1 as well as with Qt 3.0.5 (sorry, couldn't test any
older 3.0.x versions) .


Simon


Created an attachment (id=328)
test-3.cc

Created an attachment (id=329)
test-1.h
Comment 3 John Firebaugh 2002-10-31 06:09:39 UTC
*** Bug 49956 has been marked as a duplicate of this bug. ***
Comment 4 qt-bugs 2002-11-01 14:05:41 UTC
Subject: Re: [Issue N9971]  serious eventloop regression

On Wednesday, 30 Oct 2002 12:45 Simon Hausmann wrote:
> Hi Trolls,

Hello Simon,

> (qt-3.1rc1)
>
> The attached testcase shows that a null single-shot timer started from
> a slot connected to a popup menu item will get fired before the event
> loop of the menu is left.
>
> Quite some code in KDE relies on this behaviour, allowing to execute
> slots 'outside' of the local event loop. Like for example when a popup
> menu is executed from within an iconview's mouse event handler,
> providing an action that causes the iconview to get deleted and
> replace with another view. KDE in that case uses a single-shot timer
> to really perform the destructive action when the popup menu is closed
> and we're back in the previous/global event loop. The SST in that case
> is started from within the slot connected to the activated() signal of
> the menu (item) , just like in the testcase.
>
> The testcase works (as in never shows the 'timeout' debug output) with
> Qt 2.3.1 as well as with Qt 3.0.5 (sorry, couldn't test any older
> 3.0.x versions) .

This is quite true. I hadn't considered this case when I made the
eventloop changes in 3.1.

I have fixed this properly now, and hopefully we won't have problems
like this again.

Here's a patch:

==== //depot/qt/main/src/kernel/qapplication.cpp#723 (text) ====

@@ -2877,14 +2877,6 @@
 		      || receiver == pe->receiver ) // we send to THAT receiver
 		 && ( event_type == 0 // we send all types
 		      || event_type == pe->event->type() ) ) { // we send THAT type
-		// do not process DeferredDelete events if we are in
-		// the middle of a loop level change (which means
-		// exit_loop() has been called, but we have not yet
-		// returned from enter_loop()).
-		if ( eventloop && eventloop->d->exitloop &&
-		     pe->event->type() == QEvent::DeferredDelete )
-		    continue;
-
 		// first, we diddle the event so that we can deliver
 		// it, and that noone will try to touch it later.
 		pe->event->posted = FALSE;

==== //depot/qt/main/src/kernel/qeventloop.cpp#21 (text) ====

@@ -139,8 +139,9 @@
 
     // cleanup
     d->looplevel = 0;
-    d->quitnow = FALSE;
+    d->quitnow  = FALSE;
     d->exitloop = FALSE;
+    d->shortcut = FALSE;
     // don't reset quitcode!
 
     return d->quitcode;
@@ -167,8 +168,9 @@
     if ( d->quitnow ) // preserve existing quitcode
 	return;
     d->quitcode = retcode;
-    d->quitnow = TRUE;
+    d->quitnow  = TRUE;
     d->exitloop = TRUE;
+    d->shortcut = TRUE;
 }
 
 
@@ -182,6 +184,7 @@
     // save the current exitloop state
     bool old_exitloop = d->exitloop;
     d->exitloop = FALSE;
+    d->shortcut = FALSE;
 
     d->looplevel++;
     while ( ! d->exitloop )
@@ -191,10 +194,12 @@
     // restore the exitloop state, but if quitnow is TRUE, we need to keep
     // exitloop set so that all other event loops drop out.
     d->exitloop = old_exitloop || d->quitnow;
+    d->shortcut = d->quitnow;
 
     if ( d->looplevel < 1 ) {
-	d->quitnow = FALSE;
+	d->quitnow  = FALSE;
 	d->exitloop = FALSE;
+	d->shortcut = FALSE;
 	emit qApp->aboutToQuit();
 
 	// send deferred deletes
@@ -212,6 +217,7 @@
 void QEventLoop::exitLoop()
 {
     d->exitloop = TRUE;
+    d->shortcut = TRUE;
 }
 
 /*! \fn void QEventLoop::loopLevel() const

==== //depot/qt/main/src/kernel/qeventloop_p.h#6 (text) ====

@@ -86,12 +86,14 @@
 	quitcode = 0;
 	quitnow = FALSE;
 	exitloop = FALSE;
+	shortcut = FALSE;
     }
 
     int looplevel;
     int quitcode;
-    bool quitnow;
-    bool exitloop;
+    unsigned int quitnow  : 1;
+    unsigned int exitloop : 1;
+    unsigned int shortcut : 1;
 
 #if defined(Q_WS_MAC)
     EventLoopTimerRef select_timer;

==== //depot/qt/main/src/kernel/qeventloop_x11.cpp#17 (text) ====

@@ -146,6 +146,10 @@
 	while ( XPending( QPaintDevice::x11AppDisplay() ) ) {
 	    // also flushes output buffer
 	    while ( XPending( QPaintDevice::x11AppDisplay() ) ) {
+		if ( d->shortcut ) {
+		    return FALSE;
+		}
+
 		XNextEvent( QPaintDevice::x11AppDisplay(), &event );
 
 		if ( flags & ExcludeUserInput ) {
@@ -170,6 +174,10 @@
 	}
     }
 
+    if ( d->shortcut ) {
+	return FALSE;
+    }
+
     QApplication::sendPostedEvents();
 
     // don't block if exitLoop() or exit()/quit() has been called.


> Simon
>
>

--
Bradley T Hughes
Trolltech AS, Waldemar Thranes gt. 98, N-0175 Oslo, Norway

Comment 5 Simon Hausmann 2002-11-01 14:15:38 UTC
Subject: qt-copy

CVS commit by hausmann: 

- patch from Brad to fix SSTs being fired to early

CCMAIL: 49896-done@bugs.kde.org


  M +1 -0      README.qt-copy   1.176
  M +0 -8      src/kernel/qapplication.cpp   1.58
  M +9 -3      src/kernel/qeventloop.cpp   1.10
  M +4 -2      src/kernel/qeventloop_p.h   1.5
  M +8 -0      src/kernel/qeventloop_x11.cpp   1.7

Comment 6 Dirk Mueller 2002-11-02 22:01:13 UTC
*** Bug 49600 has been marked as a duplicate of this bug. ***
Comment 7 Dirk Mueller 2002-11-05 03:36:34 UTC
*** Bug 49600 has been marked as a duplicate of this bug. ***