summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qtranslator.cpp
Commit message (Collapse)AuthorAgeFilesLines
* core/gui: fix odr violationTim Blechmann2024-02-061-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | When linking Qt statically, QtCore and QtGui are not separated into different DSOs. when both statically linked versions of QtCore and QtGui are linked into the same binary with LTO, gcc emits: ``` /usr/src/debug/qtbase/6.3.0-r0/git/src/gui/painting/qicc.cpp:105: warning: type ‘Tag’ violates the C++ One Definition Rule [-Wodr] /usr/src/debug/qtbase/6.3.0-r0/git/src/corelib/kernel/qtranslator.cpp:78: note: an enum with different value name is defined in another translation unit /usr/src/debug/qtbase/6.3.0-r0/git/src/gui/painting/qicc.cpp:106: note: name ‘acsp’ differs from name ‘Tag_End’ defined in another translation unit /usr/src/debug/qtbase/6.3.0-r0/git/src/corelib/kernel/qtranslator.cpp:78: note: mismatching definition ``` we therefore define the `struct Tag` in an anonymous namespace or the QIcc namespace Change-Id: Ib4edeede35c51322ab1959d70fb87359b196e59b Pick-to: 6.5 6.6 6.7 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Remove remnants of Qt for Native Client (NACL)Tor Arne Vestbø2023-09-231-1/+1
| | | | | | | | | The project has been superseded by Qt for WebAssembly and was never supported in Qt 6. Pick-to: 6.6 6.5 Change-Id: I36682cfe3ce6adac76a307b0faba97dcb7c655cc Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Give QLocale::uiLanguages() a separator parameterEdward Welbourne2023-08-161-3/+1
| | | | | | | | | | | | | | | | | | | It has always returned dash-joined forms of the locale names, and callers who need an underscore-joined form have been obliged to replace('-', '_') before using them. Given that everything it adds to the list comes from QLocaleId methods that accept a separator, it's trivial to let it offer the same choice to its callers and save them this hassle. Amended code in QTranslater and QMimeType to save them that hassle. [ChangeLog][CoreLib][QLocale] QLocale::uiLanguages() now lets the caller choose what separator to use between the tags that make up each locale-identifier in the list returned. Change-Id: I91fcd0b988d9a64e0e9ad9e851f6cb8c1be8ae50 Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Replace ushort*/uint* with char16_t*/char32_t* in private API [1]Ahmad Samir2023-03-151-1/+1
| | | | | | | Task-number: QTBUG-110403 Pick-to: 6.5 Change-Id: Ie20a831f22212d56659cf3c6940d17134ab5f2c5 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Port from qAsConst() to std::as_const()Marc Mutz2022-10-111-1/+1
| | | | | | | | | | | | | | | | We've been requiring C++17 since Qt 6.0, and our qAsConst use finally starts to bother us (QTBUG-99313), so time to port away from it now. Since qAsConst has exactly the same semantics as std::as_const (down to rvalue treatment, constexpr'ness and noexcept'ness), there's really nothing more to it than a global search-and-replace, with manual unstaging of the actual definition and documentation in dist/, src/corelib/doc/ and src/corelib/global/. Task-number: QTBUG-99313 Change-Id: I4c7114444a325ad4e62d0fcbfd347d2bbfb21541 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* Port from container.count()/length() to size()Marc Mutz2022-10-041-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is semantic patch using ClangTidyTransformator: auto QtContainerClass = expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o) makeRule(cxxMemberCallExpr(on(QtContainerClass), callee(cxxMethodDecl(hasAnyName({"count", "length"), parameterCountIs(0))))), changeTo(cat(access(o, cat("size"), "()"))), cat("use 'size()' instead of 'count()/length()'")) a.k.a qt-port-to-std-compatible-api with config Scope: 'Container'. <classes> are: // sequential: "QByteArray", "QList", "QQueue", "QStack", "QString", "QVarLengthArray", "QVector", // associative: "QHash", "QMultiHash", "QMap", "QMultiMap", "QSet", // Qt has no QMultiSet Change-Id: Ibe8837be96e8d30d1846881ecd65180c1bc459af Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QTranslator: generalize a UNIX-only pathGiuseppe D'Angelo2022-08-101-2/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | QTranslator builds a list of "candidate" names in order to find out the translation file to load. Part of the name comes from the UI languages, as determined by the QLocale object passed to load() (via QLocale::uiLanguages()). On UNIX this list of languages is processed by adding a lowercase version of each language. In other words, if the list is something like: {"en-Latn-US", "en-US", "en"} then it is changed to contain: {"en-Latn-US", "en-latn-us", "en-US", "en-us", "en"} (The last element is not needlessly duplicated, since it's already fully lowercase.) I am not sure why this is done only on UNIX: the commit introducing this behavior predates public history. If I have to take a guess, it's done because the language is then used to assemble a file name that QTranslator tries to open. On UNIX file names are case sensitive, so if the translation file is called "translations_en_us.qm" it would fail to load under a "en-US" locale (the "-" -> "_" processing is done later). But what about Windows? In principle, turning the names in lowercase is not necessary as Windows' filesystem is case insensitive; a translation file called "translations_en_us.qm" will still be loaded if opened as "translations_en_US.qm"... ... *except* if the file is in the resource system! In that case, filesystem access is still case sensitive, and will fail to load the translation file (which instead would load just fine on UNIX). Plug this silly cross-platform difference by also lowercasing on Windows. Change-Id: I2573721e33d9da08f60a5bb56e35e4553cbe4efe Pick-to: 5.15 6.2 6.3 6.4 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Kai Koehne <kai.koehne@qt.io>
* Use SPDX license identifiersLucie Gérard2022-05-161-38/+2
| | | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Task-number: QTBUG-67283 Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* QtCore: replace QLatin1String/QLatin1Char with _L1/u'' where applicableSona Kurazyan2022-03-251-7/+7
| | | | | | | | | | | As a drive-by, did also minor refactorings/improvements. Task-number: QTBUG-98434 Change-Id: I81964176ae2f07ea63674c96f47f9c6aa046854f Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru>
* corelib: Fix typos in documentationJonas Kvinge2021-10-121-1/+1
| | | | | | Pick-to: 5.15 6.2 Change-Id: I64d63af708bc6ddaabd12450eb3089e5077f849e Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QTranslator: Fix loading of meta catalogs from absolute .qm pathKai Köhne2021-07-151-3/+8
| | | | | | | | | | | | | | | In case of QTranslator translator; translator.load("somedir/file.qm"); and file.qm being a meta catalog file, the sub-catalogs in somedir couldn't be located, unless "somedir" was set as second argument. Pick-to: 5.15 6.1 6.2 Fixes: QTBUG-95013 Change-Id: I06103244ce2ff9800c2c64cb0c17f9bc7ef0e8de Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* Fix QTranslator::load() search order not following uiLanguages orderKarsten Heimrich2020-12-031-25/+9
| | | | | | | | | | | | Merge the exact and and fuzzy search loop. This way we prioritize translations which match a more preferred language loosely over ones which match a less preferred language exactly. This is likely what most users want. Pick-to: 5.15 6.0 Fixes: QTBUG-86179 Change-Id: Id1610c82a2e77edf9a5d4417968dcc4c307810d5 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* Whitespace cleanup in corelib/kernelAllan Sandfeld Jensen2020-10-241-5/+5
| | | | | Change-Id: If061ef0af5ced4384e20a82afcea3712fa7e45d7 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Port remaining usages of QStringRef in QtCore to QStringViewLars Knoll2020-06-121-2/+2
| | | | | | Task-number: QTBUG-84319 Change-Id: If77bc94c18e8d522b4577050091cd7d7aa941311 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix check for malformed input when decoding translationsVolker Hilsheimer2020-06-051-1/+1
| | | | | | | | | | | | | | | | Any integer modulo 1 can never be anything else but 0, so the statement could never be true. The intention is to abort in case of an odd number of bytes, as this would indicate malformed input that can't be decoded into a QString. Note that QTranslator will then silently continue to search for valid translations, and not print any error message at runtime, or otherwise inform the user or developer that an input message file contains malformed content. Change-Id: I957b337ee035f3aca013e0859f8ee70553d9a97b Coverity-Id: 11014 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* QTranslator: replace manual memory handling with std::unique_ptrMarc Mutz2020-06-021-18/+14
| | | | | | | | The QTranslator owns its QResource and its sub-translators, so hold them in unique_ptr to show what's going on. Change-Id: I65dfa8c3b6dd774066a01de23ae6cff7449b363a Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Merge remote-tracking branch 'origin/5.15' into devQt Forward Merge Bot2020-05-051-2/+3
|\ | | | | | | Change-Id: I003c0d6271c6444748bf30b4331eca3fb2410f44
| * Improve QTranslator documentation code snippetKai Koehne2020-05-051-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Use :/i18n/, because this is the place where translations are stored by default if using qmake's CONFIG += lrelease embed_translations. Also revert change of app.exec() done in 16da0b2cf8b6b. First of all, both QGuiApplication and QApplication feature overloads of exec(), so using QCoreApplication::exec() might miss functionality. Anyhow, while it's true that all of them are static member functions, the vast majority of our examples and templates call them with class member access syntax, so let's try to be consistent. Finally, the example since a while uses QCoreApplication::translate, not tr(), so let's not mention it in the description. Change-Id: Ic6e5d91cf04d3f0d1a4296c5c09e790773e6fc62 Reviewed-by: Miłosz Kosobucki <milosz@kosobucki.pl> Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* | Merge remote-tracking branch 'origin/5.15' into devLiang Qi2020-02-131-3/+39
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: examples/widgets/graphicsview/boxes/scene.h src/corelib/Qt5CoreMacros.cmake src/corelib/Qt6CoreMacros.cmake src/network/ssl/qsslsocket.cpp src/network/ssl/qsslsocket.h src/platformsupport/fontdatabases/windows/qwindowsfontenginedirectwrite.cpp src/testlib/CMakeLists.txt src/testlib/.prev_CMakeLists.txt tests/auto/corelib/tools/qscopeguard/tst_qscopeguard.cpp Disabled building manual tests with CMake for now, because qmake doesn't do it, and it confuses people. Done-With: Alexandru Croitor <alexandru.croitor@qt.io> Done-With: Volker Hilsheimer <volker.hilsheimer@qt.io> Change-Id: I865ae347bd01f4e59f16d007b66d175a52f1f152
| * QTranslator: Expose language of translation fileKai Koehne2020-02-101-2/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This allows for instance to show the current UI language in the UI, or to load additional translations that match the .qm file by other means. This is especially useful in the case of QTranslator::load(QLocale(), ...), in which case different language and country combinations might be tried. Another option is to inspect the file name via QTranslator::filePath(); however, this is more error-prone, and might also miss information (if the .qm file name doesn't have a country suffix, or no suffix at all). Change-Id: I6f565d53d8f50e21241ccae6c4de264747ac8f81 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
| * QTranslator: Expose origin file of the translationKai Koehne2020-02-101-1/+22
| | | | | | | | | | | | | | Task-number: QTBUG-36608 Change-Id: I8ef0968404370b8fc25dc8b4c1e2c9e4484ae55c Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Merge remote-tracking branch 'origin/5.15' into devQt Forward Merge Bot2019-12-091-19/+19
|\| | | | | | | Change-Id: Ia24cc8b86def0d9d9c17d6775cc519e491b860b1
| * Tidy nullptr usageAllan Sandfeld Jensen2019-12-061-19/+19
| | | | | | | | | | | | | | | | | | | | | | Move away from using 0 as pointer literal. Done using clang-tidy. This is not complete as run-clang-tidy can't handle all of qtbase in one go. Change-Id: I1076a21f32aac0dab078af6f175f7508145eece0 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | Use same condition for QT_USE_MMAP as in qresource.cppTobias Hunger2019-10-011-4/+4
|/ | | | | | | | Consistently use the same condition to decide whether or not to set QT_USE_MMAP. Change-Id: Ica83d40c8051a8957d875334b821037b25fa8677 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QResource: deprecate isCompressed()Thiago Macieira2019-07-161-1/+2
| | | | | | | | | | | | Current codebases assume isCompressed() implies ZlibCompression, since there was no compressionAlgorithm() getter. In order to force codebases to change, deprecate isCompressed() and force handling of the algorithm. The replacement API is being introduced in 5.14, which is why the warning is being emitted in 5.15 only. Change-Id: Ief874765cd7b43798de3fffd15a9f5d978951ea5 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QTranslator: simplify QString byte-swapping codeThiago Macieira2019-06-281-5/+2
| | | | | | | | | No need to check QSysInfo, just use qFromBigEndian. On big-endian systems, it does the memcpy for us. Change-Id: I1004b4b819774c4c9296fffd158fe3aa5ff0a287 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Merge remote-tracking branch 'origin/5.12' into 5.13Qt Forward Merge Bot2019-04-101-1/+1
|\ | | | | | | Change-Id: I44eda44bf424fdcffab048a2534905d6162e5559
| * Fix off-by-one error in QTranslatorPrivate::do_load()Edward Welbourne2019-04-091-1/+1
| | | | | | | | | | | | | | | | | | | | The central loop starts by reading five bytes; but the loop condition only checked that four were available. Change-Id: I244cecacabeffbac10ad94081f32847f912d95d9 Reviewed-by: Kai Koehne <kai.koehne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: hjk <hjk@qt.io>
* | Merge remote-tracking branch 'origin/5.12' into 5.13Qt Forward Merge Bot2019-03-201-1/+2
|\| | | | | | | | | | | | | | | | | | | Conflicts: src/gui/kernel/qplatformintegration.cpp src/gui/kernel/qplatformintegration.h src/plugins/platforms/wasm/qwasmintegration.cpp src/plugins/platforms/xcb/qxcbconnection_screens.cpp Change-Id: I15063d42e9a1e226d9d2d2d372f75141b84c5c1b
| * QTranslator: avoid unhandled exceptionAnton Kudryavtsev2019-03-161-1/+2
| | | | | | | | | | | | | | | | | | | | Add std::nothrow param to avoid exception and to check pointer against nullptr. Change-Id: I505abb1ca15b8c10a80b0cd3784a6b0c4c6bcc1c Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* | QTranslator: add initial largefile supportThiago Macieira2018-12-041-20/+13
|/ | | | | | | | | | Using QT_MMAP macro instead of mmap() so we could map more than 2 GB of the file. Not that the file format supports such a thing, but just in case. Change-Id: Iae320a2868db402a993dfffd15689bba1d667c7d Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Allow loading of empty translation filesKai Koehne2018-07-121-6/+4
| | | | | | | | | | | | | | | | | | | | | Do not return false for loading an empty .qm file - that is, a valid file without any translations. We're already shipping empty .qm files for English translations of Qt since a while, mainly as a stop for the QTranslator::load(const QLocale &, ...) logic. Note that QCoreApplication::installTranslator() will still return false for an empty translation file - which is ok, because it arguably does not make much sense to install it. [ChangeLog][QtCore][QTranslator] It is now possible to load qm files without any translations. This is particularly useful for the language the untranslated strings are written in; logic to load translations can now handle the source language like all other languages. Task-number: QTBUG-31031 Change-Id: Ibcb84aa755538cb2fa21b14f8635295a58440bbb Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
* Add qbswap for a memory regionThiago Macieira2018-07-041-2/+3
| | | | | | | | | | | | The compiler was generating some vectorized code for qresource.cpp but it wasn't very efficient. So improve upon it and make use in other places where we read UTF-16BE strings. [ChangeLog][QtCore] Added an overload of q{To,From}{Big,Little}Endian that operates on a memory region. Change-Id: I6a540578e810472bb455fffd1531fa2f1d724dfc Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* doc: Fix three "Cannot tie" errorsMartin Smith2017-12-021-1/+1
| | | | | | | | | | Two of the three functions were for functions that should not be documented. The third was a function protected by #ifndef Q_OS_DARWIN, which required a test of Q_CLANG_QDOC in the header and cpp files. Change-Id: Id2ab3e4f2ea896dc628a622de2e80a19c18eb9fe Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* QtCore: include mocsThiago Macieira2017-05-051-0/+2
| | | | | | | | | | | | | | | | | | | Compilation and link times in CPU seconds with GCC 7, using precompiled headers (not including moc, rcc, uic, etc. steps or headersclean): Before After Debug -O0 198,1 180,3 Debug -Og 240,7 229,2 Release -O3 267,1 249,2 Release LTO 239,4 229,8 QtCore required a little manual adjusting because some files are bootstrapped into moc itself and into qmake. Change-Id: I84e363d735b443cb9beefffd14b8b57c10e7da36 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Marc Mutz <marc.mutz@kdab.com> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
* QTranslator: use const to avoid detach()'ingAnton Kudryavtsev2016-08-111-2/+1
| | | | | | Change-Id: Idbab696affed9486e9077d72ba14ce409b98174c Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* CoreLib: use QStringRef to optimize memory allocationAnton Kudryavtsev2016-07-021-1/+1
| | | | | | | | | | | Replace substring functions that return QString with corresponding functions that return QStringRef where it's possible. Create QString from QStringRef only where necessary. Change-Id: Id9ea11b16947220cd27787c0b529de62d10b6c26 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QTranslator: optimize string and char usageAnton Kudryavtsev2016-01-281-2/+2
| | | | | | | | | | | Port a QString::fromLatin1() to QStringLiteral. The string is never modified. Wrap char in QLatin1Char to construct a QChar with 8-bit character. Change-Id: I579ca9eae0c2a72ea893254f258b001063e9f64e Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* QTranslator: don't re-create QString each time through a loopAnton Kudryavtsev2016-01-261-2/+5
| | | | | | | | | | | | | Just cache it. Also port to QStringLiteral, because the string is never modified. Since the string literal is used in more than one function, to avoid duplication of .rodata, wrap the QStringLiteral in an inline function. Change-Id: Ib5aede9f129610c80d122939afc343c938cc8e48 Reviewed-by: Marc Mutz <marc.mutz@kdab.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>
* QTranslator: enable NRVO in find_translation() for poor compilersMarc Mutz2016-01-121-1/+2
| | | | | | | | | | | | | | | ... such as GCC. truncate(0) was chosen because it is already used throughout the function. Using clear(), say, which is inline, produces slightly more code. As is, saves 160b in text size on optimized GCC 4.9 Linux AMD64 builds. Change-Id: I415d09ad2b4547f1d69f78d85e2aa1c1f9a17ed3 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
* QTranslator: optimize string handling in find_transformationMarc Mutz2016-01-121-1/+2
| | | | | | | | | | - Don't repeatedly truncate a (shared) QString, truncate a QStringRef instead, preventing a detach. Change-Id: I1a9cf7fc5bc9ea06279f7e2548f2bd144b8780a3 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
* QtCore: eradicate all Q_FOREACH loops [kernel]Marc Mutz2016-01-121-3/+3
| | | | | | | | Saves just 168b in text size on optimized GCC 4.9 Linux AMD64 builds, but most for loops are in non-Linux code. Change-Id: I4f20a65c2e4953011308ff831c9e8fa37a25274b Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QTranslator: don't repeatedly re-create a QString from a QLatin1StringMarc Mutz2016-01-111-2/+3
| | | | | | | | | | | | | ... each time around the loops. Cache it. Also use QStringLiteral, since the string will never be modified. Also saves 96b in text size on optimized GCC 4.9 Linux AMD64 builds. Change-Id: I0269586235da18f3073a553739561ea7db6356e8 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* QTranslator: re-use 'realname' capacity in find_translation()Marc Mutz2016-01-111-7/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | For almost the whole of its life time, 'realname' has the same prefix, but the old code used the same string-builder expression to construct it over and over again. If QStringBuilder would re-use the capacity of the LHS object, that would boil down to just a bit more copying of characters than necessary. But assigning a QStringBuilder expression to a QString works by implicit conversion of the QStringBuilder expression to a QString, followed by move-assigning the new QString into the old. The new code keeps the common prefix around, resetting 'realname' to that prefix with truncate, only appending the varying suffixes. In this way, one memory allocation per assignment is saved (ignoring a potentially required capacity increase in one of the appends here), and also some out-of-line QString dtor calls, since op+=(QString&, QStringBuilder...) doesn't create a temporary QString. Also saves ~1KiB in text size on optimized GCC 4.9 Linux AMD64 builds. Change-Id: I0872a69c9111d7218567f06f8fefb010f2430532 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QTranslator: Extract Method is_readable_file from find_translation()Marc Mutz2016-01-041-15/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The old code re-used a QFileInfo object, repeatedly setting new file names with QFileInfo::setFile(QString). But QFileInfo::setFile() simply assigns itself a new QFileInfo object: *this = QFileInfo(...) so it's just as efficient to re-create a new QFIleInfo object for every file name under test. To avoid extra {} for object lifetime scoping, factor the repeated evaluation of isReadable() && isFile() into a small helper function, which also creates and destroys the QFileInfo object. The deeper significance of this change is that it avoids implicit sharing of 'realname', which is permanently modified. A later patch will make changes that make 'realname' re-use its capacity through the lifetime of the find_translation() function, and sharing the variable implicitly will nip any auch attempts in the bud. Force the compiler to not inline the new function. There's really no point in spending ~0.5KiB in text size on inlining the code; the miniscule speed improvement is dwarfed by the memory allocation of the QFileInfo ctor, anyway. As a consequence, this change even saves 96b in text size on optimized GCC 4.9 Linux AMD64 builds, even though that wasn't even the goal. Change-Id: I08c5cbb7b6f1ba59440a1597e28d962ce63a7c65 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Merge remote-tracking branch 'origin/5.5' into devFrederik Gladhorn2015-08-061-1/+1
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: doc/global/qt-cpp-defines.qdocconf src/3rdparty/forkfd/forkfd.c src/corelib/codecs/qtextcodec.cpp src/corelib/kernel/qmetatype.cpp src/corelib/tools/qset.qdoc src/gui/accessible/qaccessible.cpp src/gui/image/qpixmapcache.cpp src/opengl/qgl.cpp src/tools/qdoc/generator.cpp src/widgets/kernel/qwidget.cpp tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp Change-Id: I4fbe1fa756a54c6843aa75f4ef70a1069ba7b085
| * Doc: Don't advertise QLocale::system() in QTranslator::load documentationKai Koehne2015-07-231-1/+1
| | | | | | | | | | | | | | | | | | | | Usually you want to use just QLocale(), and not QLocale::system(). They are both the same except when the user called QLocale::setDefault() beforehand. Change-Id: I2d9b13ac3ffec0005b1d9bf661eccdea276d34b1 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> Reviewed-by: Martin Smith <martin.smith@digia.com>
* | Remove <qhash.h> where it's not usedMarc Mutz2015-04-201-1/+0
|/ | | | | | | | To avoid source-incompatibilites, wrap in QT_DEPRECATED_SINCE(5, 5) in public headers. Change-Id: I6117e8a6b11200d2f1a0a94a0e87d5c27538218e Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.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>