summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qiodevice_p.h
Commit message (Collapse)AuthorAgeFilesLines
* QIODevice: use QVLA to hold the ring buffers, not QListMarc Mutz2021-12-151-3/+3
| | | | | | | | | | | | | | | The only users of more than one read- or write channel are the SCTP code and QProcess. SCTP being pretty rare, optimize for the common case of at most two QRingBuffers for reading (QProcess) and one for writing. Even with more channels, QVLA shouldn't be slower than QList - on the contrary. Need to adjust tst_toolsupport and TypeInformationVersion, as QFilePrivate::fileName has changed. Pick-to: 6.3 Change-Id: I3baf982ba1f4dc51463be8730e414f6164072d8b Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QIODevice: rework validation policy for read() functionsAlex Trotsenko2021-08-011-0/+1
| | | | | | | | | | | - avoid calls to private and virtual functions, if the device is not open; - avoid repetitive checks in loops; - add missing checks in readLine() overloads; - remove check against unsuccessful resize(). Change-Id: I973d5931163b25db1c09c7c3b66f29ea90bb1b29 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* QLocalSocket/Win: avoid double buffering on writeAlex Trotsenko2021-06-091-0/+7
| | | | | | | | | As QWindowsPipeWriter now maintains a chunk queue, there is no need to use the internal QIODevice buffer and wait for the previous operation to complete. Change-Id: Id4d54edfe920aeb4a534980cb0cc85a56c067a70 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* Whitespace cleanup in corelib/iov6.0.0-beta2Allan Sandfeld Jensen2020-10-201-1/+2
| | | | | | | | | Selective application of clang-format to follow our coding style where it is significantly off. Change-Id: I0ff4ed146fe53922691d5473d0c236f31d478a04 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* QIODevicePrivate: rearrange class membersAlex Trotsenko2020-08-241-20/+26
| | | | | | | | | | | | | | As this class is a subject of the library hook data, there must be a solid understanding of the member's alignment and padding across different architectures. By reordering the layout, this patch provides a clearer way of adding new members to the class. Bump the TypeInformationVersion field in qtHookData, to notify the Qt Creator developers that the offset of QFilePrivate::fileName was changed and dumpers should be adapted. Change-Id: Ied8b69bdeb9da50ff05aba2107bc75509674b18e Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QIODevice: implement a "zero-copy" strategy for buffered writesAlex Trotsenko2020-08-201-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | It works as follows: - user calls write(const QByteArray &); - this function keeps a pointer to the chunk and calls a regular write(data, len); - write(data, len) calls a virtual writeData(); - subclass calls a new QIODevicePrivate::write(); - QIODevicePrivate::write() makes a shallow copy of the byte array. Proposed solution is fully compatible with existing subclasses. By replacing a call to d->writeBuffer.append() with d->write(), subclasses can improve their performance. Bump the TypeInformationVersion field in qtHookData, to notify the Qt Creator developers that the offset of QFilePrivate::fileName was changed and dumpers should be adapted. Change-Id: I24713386cc74a9f37e5223c617e4b1ba97f968dc Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Introduce QIODevice::skipData()Alex Trotsenko2020-08-111-2/+0
| | | | | | | | | | | | | | | | | | | QIODevice::skip() called a virtual QIODevicePrivate::skip() to implement an efficient skipping on I/O devices for the internal subclasses. The user subclasses cannot inherit QIODevicePrivate, so this functionality was not externally accessible. This patch replaces QIODevicePrivate::skip() with a virtual protected QIODevice::skipData(). While the basic implementation simply discards the data by reading into a dummy buffer, users can reimplement this function to improve the performance in their subclasses. [ChangeLog][QtCore][QIODevice] Added virtual protected skipData(). Now, subclasses can implement device-specific skipping of data. Change-Id: I9522f7f7ab9d03ac06e972a525f8ec2fa909a617 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Use QList instead of QVector in corelibJarek Kobus2020-06-251-4/+4
| | | | | | | | | | Applied to headers only. Source file to be changed separately. Omitted statemachine for now to avoid conflicts. Omitted qmetatype.h for now - to be handled later. Task-number: QTBUG-84469 Change-Id: I317376037a62467c313467d92955ad0b7473aa97 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* Replace Q_NULLPTR with nullptr where possibleKevin Funk2017-09-191-2/+2
| | | | | | | | | | | | | Remaining uses of Q_NULLPTR are in: src/corelib/global/qcompilerdetection.h (definition and documentation of Q_NULLPTR) tests/manual/qcursor/qcursorhighdpi/main.cpp (a test executable compilable both under Qt4 and Qt5) Change-Id: If6b074d91486e9b784138f4514f5c6d072acda9a Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* Introduce QIODevice::skip()Alex Trotsenko2017-08-271-0/+3
| | | | | | | | | | [ChangeLog][QtCore][QIODevice] Added skip() method to improve performance in read operations. Change-Id: I79068a3e9df108756abe37ba3d431e27e7413621 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Improve QIODevice::peek() performance on buffered devicesAlex Trotsenko2017-02-091-1/+1
| | | | | | | | | | | | | | Since 5.7, QIODevice::peek() implementation is based on transaction mechanism. While technically it's correct, seeking backward on a buffered random-access device clears the internal buffer that affects the performance of reading. To solve the problem, this patch implements peek mode directly inside the reading procedure. Task-number: QTBUG-56032 Change-Id: Ic5269f76e44c491a0309e13aba87fa7cf7b9259f Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Refactor QIODevice::read()Alex Trotsenko2017-02-091-0/+1
| | | | | | | | | Move device-dependent part of the code into the private function for further reusing by peek() procedure. Task-number: QTBUG-56032 Change-Id: Iedceafe4b0bab109ca5c64ad274d779efe87c27b Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Introduce SCTP sockets supportAlex Trotsenko2016-07-271-0/+2
| | | | | | | Add protocol-specific code and the QSctpServer, QSctpSocket classes. Change-Id: Ie9a1d87bd1fda866a2405043d1c15c12ded5a96e Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QRingBuffer: allow to change the chunk size of the buffer dynamicallyAlex Trotsenko2016-07-231-0/+2
| | | | | | Change-Id: I0ac55713c7bb8c48d2c9c774376543caef781980 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QRingBuffer: add append(const char *, qint64) functionAlex Trotsenko2016-02-011-0/+1
| | | | | | | This allows to remove a code duplication in several places. Change-Id: I49f56e951682dbd2968923654a12cba5199a2502 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
* QIODevice: make the read/write chunk sizes configurableAlex Trotsenko2016-01-271-1/+3
| | | | | | | | | | | | | | | By default, the read chunk size is QIODEVICE_BUFFERSIZE and the write chunk size is 0 (which means that we don't use the internal write buffer). Derived classes may override these values to define the size of QIODevice's write buffer or to optimize the read buffer use. Bump the TypeInformationVersion field in qtHookData, to notify the Qt Creator developers that the offset of QFilePrivate::fileName was changed and dumpers should be adapted. Change-Id: Ib732bc94be8da8a5514a6e5dcc04445895f130d8 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
* QIODevice: add infrastructure for multistreamingAlex Trotsenko2016-01-271-1/+54
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some sequential devices allow data to be partitioned into several channels that have the property of independently sequenced delivery. Supporting such devices uniformly requires a unified API which provides the user with a uniform concept of multistreaming. This patch is based on QProcess's multiplexing model and introduces the following features: - ability to get the number of channels; - multiple internal read/write buffers; - channel selection functions; - notification signals on channel activity. To keep the source code compatible with single-channel implementations, introduce a private class that references the current read buffer and hides multistreaming internals from the user. Bump the TypeInformationVersion field in qtHookData, to notify the Qt Creator developers that the offset of QFilePrivate::fileName was changed and dumpers should be adapted. [ChangeLog][QtCore] Added multistreaming to QIODevice. Change-Id: Idcaa6a618927c101c4c7284d2a633913be6a6ee2 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
* Updated license headersJani Heikkinen2016-01-151-14/+20
| | | | | | | | | | | From Qt 5.7 -> LGPL v2.1 isn't an option anymore, see http://blog.qt.io/blog/2016/01/13/new-agreement-with-the-kde-free-qt-foundation/ Updated license headers to use new LGPL header instead of LGPL21 one (in those files which will be under LGPL v3) Change-Id: I046ec3e47b1876cd7b4b0353a576b352e3a946d9 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* QIODevice: handle incomplete readsAlex Trotsenko2016-01-121-133/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Introduce a transaction mechanism that gives the ability to read the data atomically. Current implementation supports transactions for both types of devices. For sequential devices, it records the whole input stream during transaction. For random-access devices, device position is saved when transaction starts. If an error occurs, the application may be able to recover the input stream by rolling back to the start point. Also, QIODevice::peek() was rewritten to make use of transactions internally. The replacement of QIODevicePrivateLinearBuffer by QRingBuffer is closely entangled with that, which makes it unfeasible to do separately. Bump the TypeInformationVersion field in qtHookData, to notify the Qt Creator developers that the offset of QFilePrivate::fileName was changed and dumpers should be adapted. [ChangeLog][QtCore] Added QIODevice's startTransaction(), commitTransaction(), rollbackTransaction(), isTransactionStarted() functions to support the read transactions. Task-number: QTBUG-44418 Change-Id: I3564b343ebeeaaf7c48a1dcdb7ef0a7ffec550f2 Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
* QIODevice: remove superfluous memberAlex Trotsenko2015-07-181-1/+0
| | | | | | | | In current implementation, d->firstRead doesn't provide any performance improvement. Change-Id: I5d6e765a7d49cb546998b2c3e908e3c5600e70b1 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Merge remote-tracking branch 'origin/5.4' into 5.5Liang Qi2015-03-311-0/+2
|\ | | | | | | | | | | | | | | | | Conflicts: mkspecs/android-g++/qmake.conf qmake/generators/unix/unixmake2.cpp src/gui/image/qimage_conversions.cpp Change-Id: Ib76264b8c2d29a0228438ec02bd97d4b97545be0
| * Introduce qt_subtract_from_timeout to reduce code duplication.Daniel Teske2015-03-091-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The same qt_timeout_value function was copied 5 times in qtbase's code, so provide a common implementation in QIoDevice that can be used by everyone. This commit also corrects the remaining time calculation in QProcess::waitForBytesWritten and QProcess::waitForFinished by using this new function. For QProcess::waitForFinished, if the process started within almost exactly the timeout time passed to waitForFinished, msecs - stopWatch.elapsed() would be -1, which is a special value. Change-Id: I7b76ee6bae695eafdd02e3db03e2ff1e23a7f40c Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
* | Update copyright headersJani Heikkinen2015-02-111-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Qt copyrights are now in The Qt Company, so we could update the source code headers accordingly. In the same go we should also fix the links to point to qt.io. Outdated header.LGPL removed (use header.LGPL21 instead) Old header.LGPL3 renamed to header.LGPL3-COMM to match actual licensing combination. New header.LGPL-COMM taken in the use file which were using old header.LGPL3 (src/plugins/platforms/android/extract.cpp) Added new header.LGPL3 containing Commercial + LGPLv3 + GPLv2 license combination Change-Id: I6f49b819a8a20cc4f88b794a8f6726d975e8ffbe Reviewed-by: Matti Paaso <matti.paaso@theqtcompany.com>
* | QIODevice: remove ineffective caching membersAlex Trotsenko2015-01-201-4/+0
|/ | | | | | | | | | Most of the QIODevice functions already have a locally cached "sequential" flag. Make the rest of them follow this strategy. This eliminates the need to use private caching members. Change-Id: I0edb2c9b7c5f411c5bee25c425e7b40e3c9021d3 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: hjk <hjk@theqtcompany.com>
* Attempt to make QFile I/O 64-bit safeThiago Macieira2014-10-311-9/+9
| | | | | | | | | | | | | | | | | | | | | Use qint64 wherever possible. The linear buffer is never requested to allocate that much memory (always limited), but at least we ensure we're not dropping bits where we shouldn't. Windows's POSIX compatibility layer is never largefile enabled, so it is always necessary to chunk large reads and writes. On Unix, this will be rare, unless someone passed -no-largefile to configure, for some weird reason. Unfortunately, this is not testable, unless we can allocate a buffer with 4 GB or more in size. The test for this would be to open a file we know to be small, then try to read 4 GB + 1 byte. If everything works correctly, we'll read the full file; if there was a truncation, we'd read one byte. Change-Id: If3ee511bf1de17e0123c85bbcaa463b9972746ce Reviewed-by: Kai Koehne <kai.koehne@theqtcompany.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Update license headers and add new license filesMatti Paaso2014-09-241-19/+11
| | | | | | | | | - Renamed LICENSE.LGPL to LICENSE.LGPLv21 - Added LICENSE.LGPLv3 - Removed LICENSE.GPL Change-Id: Iec3406e3eb3f133be549092015cefe33d259a3f2 Reviewed-by: Iikka Eklund <iikka.eklund@digia.com>
* Fix 64 bit issues in QIODevicePrivateLinearBufferLars Knoll2014-09-151-8/+8
| | | | | | | | | The API was using int, not qint64 leading to implicit truncation of numbers in a few places Task-number: QTBUG-40974 Change-Id: I13aedc84557a19b6f74fe6825764e7b5827f27b0 Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>
* Update copyright year in Digia's license headersSergio Ahumada2013-01-181-1/+1
| | | | | Change-Id: Ic804938fc352291d011800d21e549c10acac66fb Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Change copyrights from Nokia to DigiaIikka Eklund2012-09-221-24/+24
| | | | | | | | Change copyrights and license headers from Nokia to Digia Change-Id: If1cc974286d29fd01ec6c19dd4719a67f4c3f00e Reviewed-by: Lars Knoll <lars.knoll@digia.com> Reviewed-by: Sergio Ahumada <sergio.ahumada@digia.com>
* QIODevice: free memory when buffer is clearedMartin Petersson2012-06-261-4/+6
| | | | | | | | | | | | | | | The QIODevicePrivateLinearBuffer does not deallocate any data on readAll or clear. This fix will change the buffer so that data is deallocated on clear, readAll and when read emptied the buffer. This is needed for QAbstractSockets that don't have readBufferMaxSize set, as the buffer will grow but never decrease in size when you read from it. Change-Id: Iab42e40182f9ebe0739c99b2d1e820ce287dc931 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
* Fix bug in qsslsocket peek()Kalle Viironen2012-04-231-0/+5
| | | | | | | | | | | | | | | | | | Calling peek() for qsslsocket caused socket data to be copied into qiodevices buffer and therefore make it unaccessible in qsslsocket. Cherry picked form 4.8-branch & modified to Qt5 API changes (int -> qintptr) Original commits: commit 621f18955082fc73471e75d1f8c35c2dcd4befeb Author: Shane Kearns <ext-shane.2.kearns@nokia.com> commit 68b1d5c17aa38d5921bdade2b0e0cb67c6c90513 Author: Kalle Viironen <kalle.viironen@digia.com> Task-number: QTBUG-18498 Change-Id: I6be4b19baec2f3197537f5e7b61432040ec84ad2 Reviewed-by: Shane Kearns <shane.kearns@accenture.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Remove "All rights reserved" line from license headers.Jason McDonald2012-01-301-1/+1
| | | | | | | | | | As in the past, to avoid rewriting various autotests that contain line-number information, an extra blank line has been inserted at the end of the license text to ensure that this commit does not change the total number of lines in the license header. Change-Id: I311e001373776812699d6efc045b5f742890c689 Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Update contact information in license headers.Jason McDonald2012-01-231-1/+1
| | | | | | | Replace Nokia contact email address with Qt Project website. Change-Id: I431bbbf76d7c27d8b502f87947675c116994c415 Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Update copyright year in license headers.Jason McDonald2012-01-051-1/+1
| | | | | Change-Id: I02f2c620296fcd91d4967d58767ea33fc4e1e7dc Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* QtCore/IO: Fix some warnings on Windows (64bit).Friedemann Kleint2011-11-291-1/+1
| | | | | | | | - Warnings about conversion from size_t to int - Unused variable. Change-Id: I4a79fa6dc4b95551a64d282ae4307b0edff41201 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Update licenseheader text in source files for qtbase Qt moduleJyri Tahtela2011-05-241-17/+17
| | | | | | | Updated version of LGPL and FDL licenseheaders. Apply release phase licenseheaders for all source files. Reviewed-by: Trust Me
* Initial import from the monolithic Qt.Qt by Nokia2011-04-271-0/+245
This is the beginning of revision history for this module. If you want to look at revision history older than this, please refer to the Qt Git wiki for how to use Git history grafting. At the time of writing, this wiki is located here: http://qt.gitorious.org/qt/pages/GitIntroductionWithQt If you have already performed the grafting and you don't see any history beyond this commit, try running "git log" with the "--follow" argument. Branched from the monolithic repo, Qt master branch, at commit 896db169ea224deb96c59ce8af800d019de63f12