diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/io/qfsfileengine.cpp | 168 | ||||
-rw-r--r-- | src/network/kernel/qhostinfo_p.h | 6 | ||||
-rw-r--r-- | src/src.pro | 33 | ||||
-rw-r--r-- | src/tools/tools.pro | 70 |
4 files changed, 157 insertions, 120 deletions
diff --git a/src/corelib/io/qfsfileengine.cpp b/src/corelib/io/qfsfileengine.cpp index d376dc7..9ab831f 100644 --- a/src/corelib/io/qfsfileengine.cpp +++ b/src/corelib/io/qfsfileengine.cpp @@ -76,17 +76,6 @@ QT_BEGIN_NAMESPACE # endif #endif -#ifdef Q_OS_SYMBIAN - // Using default 4k block in symbian is highly inefficient due to - // the fact that each file operation requires slow IPC calls, so - // use somewhat larger block size. -# define FDFH_BLOCK_SIZE 16384 -#else - // Read/write in blocks of 4k to avoid platform limitations (Windows - // commonly bails out if you read or write too large blocks at once). -# define FDFH_BLOCK_SIZE 4096 -#endif - /*! \class QFSFileEngine \brief The QFSFileEngine class implements Qt's default file engine. \since 4.1 @@ -633,67 +622,55 @@ qint64 QFSFileEnginePrivate::readFdFh(char *data, qint64 len) { Q_Q(QFSFileEngine); - // Buffered stdlib mode. + if (len < 0 || len != qint64(size_t(len))) { + q->setError(QFile::ReadError, qt_error_string(EINVAL)); + return -1; + } + + qint64 readBytes = 0; + bool eof = false; + if (fh) { - qint64 readBytes = 0; - qint64 read = 0; - int retry = 0; + // Buffered stdlib mode. - qint64 bytesToRead; + size_t result; + bool retry = true; do { - if (retry == 1) - retry = 2; - - bytesToRead = qMin<qint64>(FDFH_BLOCK_SIZE, len - read); - do { - readBytes = fread(data + read, 1, size_t(bytesToRead), fh); - } while (readBytes == 0 && !feof(fh) && errno == EINTR); - - if (readBytes > 0) { - read += readBytes; - } else if (!retry && feof(fh)) { - // Synchronize and try again (just once though). - if (++retry == 1) - QT_FSEEK(fh, QT_FTELL(fh), SEEK_SET); + result = fread(data + readBytes, 1, size_t(len - readBytes), fh); + eof = feof(fh); + if (retry && eof && result == 0) { + // On Mac OS, this is needed, e.g., if a file was written to + // through another stream since our last read. See test + // tst_QFile::appendAndRead + QT_FSEEK(fh, QT_FTELL(fh), SEEK_SET); // re-sync stream. + retry = false; + continue; } - } while (retry == 1 || (readBytes == bytesToRead && read < len)); + readBytes += result; + } while (!eof && (result == 0 ? errno == EINTR : readBytes < len)); - // Return the number of bytes read, or if nothing was read, return -1 - // if an error occurred, or 0 if we detected EOF. - if (read == 0) { - q->setError(QFile::ReadError, qt_error_string(int(errno))); - if (!feof(fh)) - read = -1; - } - return read; - } + } else if (fd != -1) { + // Unbuffered stdio mode. - // Unbuffered stdio mode. - qint64 ret = 0; - if (len) { +#ifdef Q_OS_WIN int result; - qint64 read = 0; - errno = 0; - +#else + ssize_t result; +#endif do { - qint64 bytesToRead = qMin<qint64>(FDFH_BLOCK_SIZE, len - read); - do { - result = QT_READ(fd, data + read, int(bytesToRead)); - } while (result == -1 && errno == EINTR); - if (result > 0) - read += result; - } while (result > 0 && read < len); - - // Return the number of bytes read, or if nothing was read, return -1 - // if an error occurred. - if (read > 0) { - ret += read; - } else if (read == 0 && result < 0) { - ret = -1; - q->setError(QFile::ReadError, qt_error_string(errno)); - } + result = QT_READ(fd, data + readBytes, size_t(len - readBytes)); + } while ((result == -1 && errno == EINTR) + || (result > 0 && (readBytes += result) < len)); + + eof = !(result == -1); } - return ret; + + if (!eof && readBytes == 0) { + readBytes = -1; + q->setError(QFile::ReadError, qt_error_string(errno)); + } + + return readBytes; } /*! @@ -773,34 +750,45 @@ qint64 QFSFileEngine::write(const char *data, qint64 len) qint64 QFSFileEnginePrivate::writeFdFh(const char *data, qint64 len) { Q_Q(QFSFileEngine); - qint64 result; - qint64 written = 0; - do { - qint64 bytesToWrite = qMin<qint64>(FDFH_BLOCK_SIZE, len - written); - if (fh) { - do { - // Buffered stdlib mode. - result = qint64(fwrite(data + written, 1, size_t(bytesToWrite), fh)); - } while (result == 0 && errno == EINTR); - if (bytesToWrite > 0 && result == 0) - result = -1; - } else { - do { - // Unbuffered stdio mode. - result = QT_WRITE(fd, data + written, bytesToWrite); - } while (result == -1 && errno == EINTR); - } - if (result > 0) - written += qint64(result); - } while (written < len && result > 0); - - // If we read anything, return that with success. Otherwise, set an error, - // and return the last return value. - if (result > 0) - return written; - q->setError(errno == ENOSPC ? QFile::ResourceError : QFile::WriteError, qt_error_string(errno)); - return result; + if (len < 0 || len != qint64(size_t(len))) { + q->setError(QFile::WriteError, qt_error_string(EINVAL)); + return -1; + } + + qint64 writtenBytes = 0; + + if (fh) { + // Buffered stdlib mode. + + size_t result; + bool eof; + do { + result = fwrite(data + writtenBytes, 1, size_t(len - writtenBytes), fh); + writtenBytes += result; + eof = feof(fh); + } while (!eof && (result == 0 ? errno == EINTR : writtenBytes < len)); + + } else if (fd != -1) { + // Unbuffered stdio mode. + +#ifdef Q_OS_WIN + int result; +#else + ssize_t result; +#endif + do { + result = QT_WRITE(fd, data + writtenBytes, size_t(len - writtenBytes)); + } while ((result == -1 && errno == EINTR) + || (result > 0 && (writtenBytes += result) < len)); + } + + if (writtenBytes == 0) { + writtenBytes = -1; + q->setError(errno == ENOSPC ? QFile::ResourceError : QFile::WriteError, qt_error_string(errno)); + } + + return writtenBytes; } /*! diff --git a/src/network/kernel/qhostinfo_p.h b/src/network/kernel/qhostinfo_p.h index 64c5152..afd3570 100644 --- a/src/network/kernel/qhostinfo_p.h +++ b/src/network/kernel/qhostinfo_p.h @@ -161,9 +161,11 @@ public Q_SLOTS: cond.wakeOne(); } #ifndef QT_NO_THREAD - if (!wait(QHOSTINFO_THREAD_WAIT)) + if (!wait(QHOSTINFO_THREAD_WAIT)) { terminate(); - wait(); + // Don't wait forever; see QTBUG-5296. + wait(QHOSTINFO_THREAD_WAIT); + } #endif } diff --git a/src/src.pro b/src/src.pro index 5307612..7cab6c9 100644 --- a/src/src.pro +++ b/src/src.pro @@ -8,17 +8,12 @@ wince*:{ } else:symbian { SRC_SUBDIRS += src_s60main src_corelib src_xml src_gui src_network src_sql src_testlib src_s60installs } else { - SRC_SUBDIRS += src_tools_bootstrap src_tools_moc src_tools_rcc src_tools_uic src_corelib src_xml src_network src_gui src_sql src_testlib + SRC_SUBDIRS += src_corelib src_xml src_network src_gui src_sql src_testlib !vxworks:contains(QT_CONFIG, qt3support): SRC_SUBDIRS += src_qt3support + include(tools/tools.pro) contains(QT_CONFIG, dbus):SRC_SUBDIRS += src_dbus - !cross_compile { - contains(QT_CONFIG, qt3support): SRC_SUBDIRS += src_tools_uic3 - } -} -win32:{ - SRC_SUBDIRS += src_activeqt - !wince*: SRC_SUBDIRS += src_tools_idc } +win32:SRC_SUBDIRS += src_activeqt contains(QT_CONFIG, opengl)|contains(QT_CONFIG, opengles1)|contains(QT_CONFIG, opengles2): SRC_SUBDIRS += src_opengl contains(QT_CONFIG, openvg): SRC_SUBDIRS += src_openvg @@ -41,14 +36,6 @@ src_s60installs.subdir = $$QT_SOURCE_TREE/src/s60installs src_s60installs.target = sub-s60installs src_winmain.subdir = $$QT_SOURCE_TREE/src/winmain src_winmain.target = sub-winmain -src_tools_bootstrap.subdir = $$QT_SOURCE_TREE/src/tools/bootstrap -src_tools_bootstrap.target = sub-tools-bootstrap -src_tools_moc.subdir = $$QT_SOURCE_TREE/src/tools/moc -src_tools_moc.target = sub-moc -src_tools_rcc.subdir = $$QT_SOURCE_TREE/src/tools/rcc -src_tools_rcc.target = sub-rcc -src_tools_uic.subdir = $$QT_SOURCE_TREE/src/tools/uic -src_tools_uic.target = sub-uic src_corelib.subdir = $$QT_SOURCE_TREE/src/corelib src_corelib.target = sub-corelib src_xml.subdir = $$QT_SOURCE_TREE/src/xml @@ -79,12 +66,8 @@ src_phonon.subdir = $$QT_SOURCE_TREE/src/phonon src_phonon.target = sub-phonon src_multimedia.subdir = $$QT_SOURCE_TREE/src/multimedia src_multimedia.target = sub-multimedia -src_tools_uic3.subdir = $$QT_SOURCE_TREE/src/tools/uic3 -src_tools_uic3.target = sub-uic3 src_activeqt.subdir = $$QT_SOURCE_TREE/src/activeqt src_activeqt.target = sub-activeqt -src_tools_idc.subdir = $$QT_SOURCE_TREE/src/tools/idc -src_tools_idc.target = sub-idc src_plugins.subdir = $$QT_SOURCE_TREE/src/plugins src_plugins.target = sub-plugins src_testlib.subdir = $$QT_SOURCE_TREE/src/testlib @@ -98,9 +81,6 @@ src_declarative.target = sub-declarative #CONFIG += ordered !wince*:!symbian:!ordered { - src_tools_moc.depends = src_tools_bootstrap - src_tools_rcc.depends = src_tools_bootstrap - src_tools_uic.depends = src_tools_bootstrap src_corelib.depends = src_tools_moc src_tools_rcc src_gui.depends = src_corelib src_tools_uic embedded: src_gui.depends += src_network @@ -116,10 +96,10 @@ src_declarative.target = sub-declarative src_sql.depends = src_corelib src_testlib.depends = src_corelib src_qt3support.depends = src_gui src_xml src_network src_sql + src_tools_idc.depends = src_corelib # target defined in tools.pro + src_tools_uic3.depends = src_qt3support src_xml # target defined in tools.pro src_phonon.depends = src_gui src_multimedia.depends = src_gui - src_tools_uic3.depends = src_qt3support src_xml - src_tools_idc.depends = src_corelib src_tools_activeqt.depends = src_tools_idc src_gui src_declarative.depends = src_xml src_gui src_script src_network src_svg src_plugins.depends = src_gui src_sql src_svg @@ -146,8 +126,6 @@ sub_src_target.recurse_target = QMAKE_EXTRA_TARGETS += sub_src_target # This gives us a top level debug/release -EXTRA_DEBUG_TARGETS = -EXTRA_RELEASE_TARGETS = for(subname, SRC_SUBDIRS) { subdir = $$subname !isEmpty($${subname}.subdir):subdir = $$eval($${subname}.subdir) @@ -189,4 +167,3 @@ QMAKE_EXTRA_TARGETS += debug release } SUBDIRS += $$SRC_SUBDIRS - diff --git a/src/tools/tools.pro b/src/tools/tools.pro new file mode 100644 index 0000000..7c8fb47 --- /dev/null +++ b/src/tools/tools.pro @@ -0,0 +1,70 @@ +TEMPLATE = subdirs + +TOOLS_SUBDIRS = src_tools_bootstrap src_tools_moc src_tools_rcc src_tools_uic +!cross_compile { + contains(QT_CONFIG, qt3support): SRC_SUBDIRS += src_tools_uic3 + win32:!wince*: SRC_SUBDIRS += src_tools_idc +} + +# Set subdir and respective target name +src_tools_bootstrap.subdir = $$QT_SOURCE_TREE/src/tools/bootstrap +src_tools_bootstrap.target = sub-tools-bootstrap +src_tools_moc.subdir = $$QT_SOURCE_TREE/src/tools/moc +src_tools_moc.target = sub-moc +src_tools_rcc.subdir = $$QT_SOURCE_TREE/src/tools/rcc +src_tools_rcc.target = sub-rcc +src_tools_uic.subdir = $$QT_SOURCE_TREE/src/tools/uic +src_tools_uic.target = sub-uic +src_tools_uic3.subdir = $$QT_SOURCE_TREE/src/tools/uic3 +src_tools_uic3.target = sub-uic3 +src_tools_idc.subdir = $$QT_SOURCE_TREE/src/tools/idc +src_tools_idc.target = sub-idc + +# Set dependencies for each subdir +src_tools_moc.depends = src_tools_bootstrap +src_tools_rcc.depends = src_tools_bootstrap +src_tools_uic.depends = src_tools_bootstrap + +# Special handling, depending on type of project, if it used debug/release or only has one configuration +EXTRA_DEBUG_TARGETS = +EXTRA_RELEASE_TARGETS = +!symbian { + for(subname, TOOLS_SUBDIRS) { + subdir = $$subname + !isEmpty($${subname}.subdir):subdir = $$eval($${subname}.subdir) + subpro = $$subdir/$${basename(subdir)}.pro + !exists($$subpro):next() + subtarget = $$replace(subdir, [^A-Za-z0-9], _) + reg_src = $$replace(QT_SOURCE_TREE, \\\\, \\\\) + subdir = $$replace(subdir, $$reg_src, $$QT_BUILD_TREE) + subdir = $$replace(subdir, /, $$QMAKE_DIR_SEP) + subdir = $$replace(subdir, \\\\, $$QMAKE_DIR_SEP) + SUB_TEMPLATE = $$list($$fromfile($$subpro, TEMPLATE)) + !isEqual(subname, src_tools_bootstrap):if(isEqual($$SUB_TEMPLATE, lib) | isEqual($$SUB_TEMPLATE, subdirs) | isEqual(subname, src_tools_idc) | isEqual(subname, src_tools_uic3)):!separate_debug_info { + #debug + eval(debug-$${subtarget}.depends = $${subdir}\$${QMAKE_DIR_SEP}$(MAKEFILE) $$EXTRA_DEBUG_TARGETS) + eval(debug-$${subtarget}.commands = (cd $$subdir && $(MAKE) -f $(MAKEFILE) debug)) + EXTRA_DEBUG_TARGETS += debug-$${subtarget} + QMAKE_EXTRA_TARGETS += debug-$${subtarget} + #release + eval(release-$${subtarget}.depends = $${subdir}\$${QMAKE_DIR_SEP}$(MAKEFILE) $$EXTRA_RELEASE_TARGETS) + eval(release-$${subtarget}.commands = (cd $$subdir && $(MAKE) -f $(MAKEFILE) release)) + EXTRA_RELEASE_TARGETS += release-$${subtarget} + QMAKE_EXTRA_TARGETS += release-$${subtarget} + } else { #do not have a real debug target/release + #debug + eval(debug-$${subtarget}.depends = $${subdir}\$${QMAKE_DIR_SEP}$(MAKEFILE) $$EXTRA_DEBUG_TARGETS) + eval(debug-$${subtarget}.commands = (cd $$subdir && $(MAKE) -f $(MAKEFILE) first)) + EXTRA_DEBUG_TARGETS += debug-$${subtarget} + QMAKE_EXTRA_TARGETS += debug-$${subtarget} + #release + eval(release-$${subtarget}.depends = $${subdir}\$${QMAKE_DIR_SEP}$(MAKEFILE) $$EXTRA_RELEASE_TARGETS) + eval(release-$${subtarget}.commands = (cd $$subdir && $(MAKE) -f $(MAKEFILE) first)) + EXTRA_RELEASE_TARGETS += release-$${subtarget} + QMAKE_EXTRA_TARGETS += release-$${subtarget} + } + } +} + +SUBDIRS = $$TOOLS_SUBDIRS $$SUBDIRS +isEqual(TARGET,tools): SUBDIRS += $$SRC_SUBDIRS |