Ignore:
Timestamp:
May 5, 2011, 5:36:53 AM (14 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/gui/kernel/qclipboard_x11.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    6666#include "qdesktopwidget.h"
    6767#include "qbitmap.h"
    68 #include "qdatetime.h"
    6968#include "qiodevice.h"
    7069#include "qbuffer.h"
     
    7776#include "qx11info_x11.h"
    7877#include "qimagewriter.h"
     78#include "qelapsedtimer.h"
    7979#include "qvariant.h"
    8080#include "qdnd_p.h"
     
    133133    requestor->createWinId();
    134134    requestor->setObjectName(QLatin1String("internal clipboard requestor"));
    135     // We dont need this internal widgets to appear in QApplication::topLevelWidgets()
     135    // We don't need this internal widgets to appear in QApplication::topLevelWidgets()
    136136    if (QWidgetPrivate::allWidgets) {
    137137        QWidgetPrivate::allWidgets->remove(owner);
     
    457457        if (data.timestamp == CurrentTime) {
    458458            setupOwner();
    459             int dummy = 0;
     459            // We need this value just for completeness, we don't use it.
     460            long dummy = 0;
    460461            Window ownerId = owner->internalWinId();
    461462            XChangeProperty(X11->display, ownerId,
     
    517518bool QX11Data::clipboardWaitForEvent(Window win, int type, XEvent *event, int timeout)
    518519{
    519     QTime started = QTime::currentTime();
    520     QTime now = started;
     520    QElapsedTimer started;
     521    started.start();
     522    QElapsedTimer now = started;
    521523
    522524    if (QAbstractEventDispatcher::instance()->inherits("QtMotif")
     
    546548            usleep(50000);
    547549
    548             now = QTime::currentTime();
    549             if (started > now)                        // crossed midnight
    550                 started = now;
     550            now.start();
    551551
    552552            QEventLoop::ProcessEventsFlags flags(QEventLoop::ExcludeUserInputEvents
     
    577577                qApp->x11ProcessEvent(&e);
    578578
    579             now = QTime::currentTime();
    580             if ( started > now )                        // crossed midnight
    581                 started = now;
     579            now.start();
    582580
    583581            XFlush(X11->display);
     
    598596
    599597bool QX11Data::clipboardReadProperty(Window win, Atom property, bool deleteProperty,
    600                                      QByteArray *buffer, int *size, Atom *type, int *format, bool nullterm)
     598                                     QByteArray *buffer, int *size, Atom *type, int *format)
    601599{
    602600    int           maxsize = maxSelectionIncr(display);
     
    644642    }
    645643
    646     int newSize = proplen + (nullterm ? 1 : 0);
     644    int newSize = proplen;
    647645    buffer->resize(newSize);
    648646
     
    650648    VDEBUG("QClipboard: read_property(): buffer resized to %d", buffer->size());
    651649
    652     if (ok) {
     650    if (ok && newSize) {
    653651        // could allocate buffer
    654652
     
    686684            textprop.encoding = *type;
    687685            textprop.format = *format;
    688             textprop.nitems = length;
     686            textprop.nitems = buffer_offset;
    689687            textprop.value = (unsigned char *) buffer->data();
    690688
     
    693691            if (XmbTextPropertyToTextList(display, &textprop, &list_ret,
    694692                         &count) == Success && count && list_ret) {
    695                 offset = strlen(list_ret[0]);
    696                 buffer->resize(offset + (nullterm ? 1 : 0));
     693                offset = buffer_offset = strlen(list_ret[0]);
     694                buffer->resize(offset);
    697695                memcpy(buffer->data(), list_ret[0], offset);
    698696            }
    699697            if (list_ret) XFreeStringList(list_ret);
    700698        }
    701 
    702         // zero-terminate (for text)
    703         if (nullterm)
    704             buffer->data()[buffer_offset] = '\0';
    705699    }
    706700
     
    745739             event.xproperty.state != PropertyNewValue)
    746740            continue;
    747         if (X11->clipboardReadProperty(win, property, true, &tmp_buf, &length, 0, 0, false)) {
     741        if (X11->clipboardReadProperty(win, property, true, &tmp_buf, &length, 0, 0)) {
    748742            if (length == 0) {                // no more data, we're done
    749743                if (nullterm) {
     
    776770    requestor = new QWidget(0);
    777771    requestor->setObjectName(QLatin1String("internal clipboard requestor"));
    778     // We dont need this internal widget to appear in QApplication::topLevelWidgets()
     772    // We don't need this internal widget to appear in QApplication::topLevelWidgets()
    779773    if (QWidgetPrivate::allWidgets)
    780774        QWidgetPrivate::allWidgets->remove(requestor);
     
    839833
    840834            (void)new QClipboardINCRTransaction(window, property, atomFormat, dataFormat, data, increment);
    841             return ATOM(INCR);
     835            return property;
    842836        }
    843837
     
    10731067                if (req->property == XNone
    10741068                    || !X11->clipboardReadProperty(req->requestor, req->property, false, &multi_data,
    1075                                                    0, &multi_type, &multi_format, 0)
     1069                                                   0, &multi_type, &multi_format)
    10761070                    || multi_format != 32) {
    10771071                    // MULTIPLE property not formatted correctly
     
    12951289    XSelectInput(dpy, win, PropertyChangeMask);
    12961290
    1297     if (X11->clipboardReadProperty(win, ATOM(_QT_SELECTION), true, &buf, 0, &type, 0, false)) {
     1291    if (X11->clipboardReadProperty(win, ATOM(_QT_SELECTION), true, &buf, 0, &type, 0)) {
    12981292        if (type == ATOM(INCR)) {
    12991293            int nbytes = buf.size() >= 4 ? *((int*)buf.data()) : 0;
     
    15221516#endif
    15231517    if (!owner || (selectionOwner && selectionOwner != owner->internalWinId()) ||
    1524         (!selectionOwner && d->timestamp != CurrentTime && d->timestamp < timestamp))
     1518        (!selectionOwner && (d->timestamp == CurrentTime || d->timestamp < timestamp)))
    15251519        return qt_check_selection_sentinel();
    15261520    return false;
     
    15361530#endif
    15371531    if (!owner || (clipboardOwner && clipboardOwner != owner->internalWinId()) ||
    1538         (!clipboardOwner && d->timestamp != CurrentTime && d->timestamp < timestamp))
     1532        (!clipboardOwner && (d->timestamp == CurrentTime || d->timestamp < timestamp)))
    15391533        return qt_check_clipboard_sentinel();
    15401534    return false;
Note: See TracChangeset for help on using the changeset viewer.