]> git.pld-linux.org Git - packages/qt.git/blob - qt-0034-qclipboard_recursion_fix.patch
- desc why patches are commented out
[packages/qt.git] / qt-0034-qclipboard_recursion_fix.patch
1 qt-bugs@ issue : 15222 (part of)
2 applied: no
3 author: Lubos Lunak <l.lunak@kde.org>
4
5 This patch should fix KDE bug #61412 and its numerous duplicates (applies
6 to both Qt-3.2.x and Qt-3.3.x). I'm not opposed to trying using
7 the event loop if done properly, but right now it simply fails way too
8 often, and what's worse, qFatal() does exit(1), so there's usually
9 even no crash dialog.
10
11
12 --- src/kernel/qclipboard_x11.cpp.sav   2004-01-06 19:24:40.000000000 +0100
13 +++ src/kernel/qclipboard_x11.cpp       2004-01-22 19:48:32.000000000 +0100
14 @@ -112,10 +112,6 @@ static bool pending_selection_changed = 
15  
16  // event capture mechanism for qt_xclb_wait_for_event
17  static bool waiting_for_data = FALSE;
18 -static bool has_captured_event = FALSE;
19 -static Window capture_event_win = None;
20 -static int capture_event_type = -1;
21 -static XEvent captured_event;
22  
23  class QClipboardWatcher; // forward decl
24  static QClipboardWatcher *selection_watcher = 0;
25 @@ -432,69 +428,36 @@ bool QClipboard::selectionModeEnabled() 
26  { return inSelectionMode_obsolete; }
27  
28  
29 -// event filter function... captures interesting events while
30 -// qt_xclb_wait_for_event is running the event loop
31 -static int qt_xclb_event_filter(XEvent *event)
32 -{
33 -    if (event->xany.type == capture_event_type &&
34 -       event->xany.window == capture_event_win) {
35 -       VDEBUG( "QClipboard: event_filter(): caught event type %d", event->type );
36 -       has_captured_event = TRUE;
37 -       captured_event = *event;
38 -       return 1;
39 -    }
40 -
41 -    return 0;
42 -}
43 -
44  bool qt_xclb_wait_for_event( Display *dpy, Window win, int type, XEvent *event,
45                              int timeout )
46  {
47 -    if ( waiting_for_data )
48 -       qFatal( "QClipboard: internal error, qt_xclb_wait_for_event recursed" );
49 -
50 -    waiting_for_data = TRUE;
51 -
52      QTime started = QTime::currentTime();
53      QTime now = started;
54 -
55 -    has_captured_event = FALSE;
56 -    capture_event_win = win;
57 -    capture_event_type = type;
58 -
59 -    QX11EventFilter old_event_filter = qt_set_x11_event_filter(qt_xclb_event_filter);
60 +    bool flushed = FALSE;
61  
62      do {
63 -       if ( XCheckTypedWindowEvent(dpy,win,type,event) ) {
64 -           waiting_for_data = FALSE;
65 -           qt_set_x11_event_filter(old_event_filter);
66 +       if ( XCheckTypedWindowEvent(dpy,win,type,event) )
67             return TRUE;
68 -       }
69  
70         now = QTime::currentTime();
71         if ( started > now )                    // crossed midnight
72             started = now;
73  
74 -       // 0x08 == ExcludeTimers for X11 only
75 -       qApp->eventLoop()->processEvents( QEventLoop::ExcludeUserInput |
76 -                                         QEventLoop::ExcludeSocketNotifiers |
77 -                                         QEventLoop::WaitForMore | 0x08 );
78 -
79 -       if ( has_captured_event ) {
80 -           waiting_for_data = FALSE;
81 -           *event = captured_event;
82 -           qt_set_x11_event_filter(old_event_filter);
83 -           return TRUE;
84 +       if(!flushed) {
85 +           XFlush( dpy );
86 +           flushed = TRUE;
87         }
88 -    } while ( started.msecsTo(now) < timeout );
89  
90 -    waiting_for_data = FALSE;
91 -    qt_set_x11_event_filter(old_event_filter);
92 +       // sleep 50ms, so we don't use up CPU cycles all the time.
93 +       struct timeval usleep_tv;
94 +       usleep_tv.tv_sec = 0;
95 +       usleep_tv.tv_usec = 50000;
96 +       select(0, 0, 0, 0, &usleep_tv);
97 +    } while ( started.msecsTo(now) < timeout );
98  
99      return FALSE;
100  }
101  
102 -
103  static inline int maxSelectionIncr( Display *dpy )
104  { return XMaxRequestSize(dpy) > 65536 ? 65536*4 : XMaxRequestSize(dpy)*4 - 100; }
105  
This page took 0.07576 seconds and 3 git commands to generate.