Commit Graph

726 Commits

Author SHA1 Message Date
Craig Scott
fa9f13f130 Handle empty string args for versionless wrappers of dbus CMake commands
CMake silently drops empty list items when passing ${someVar} to a
function unquoted. The versionless wrapper functions typically use
${ARGV} or ${ARGN} to pass through arguments from the caller to the
versioned implementation, but this doesn't preserve empty arguments.
For qt_add_dbus_adaptor() in particular, this was problematic because
that meant arguments after the empty arg effectively "moved left" and
were interpreted as the wrong arguments.

Use named arguments and pass through each one explicitly for the
qt_add_dbus_adaptor(). This takes advantage of the implementation of
the versioned function, which also checks each optional positional
argument explicitly. We can only do this because we know the upper
bound on the number of arguments, so it is possible to represent each
argument with its own variable. A more general solution that didn't
need to know the number of arguments would require the
cmake_language(EVAL) command, but that requires CMake 3.18 or later.

Fixes: QTBUG-96594
Pick-to: 6.2
Change-Id: Ibb1de19217191768ca5ead969b20a1d28c466868
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-09-20 14:23:14 +10:00
Kai Köhne
6faa6cb1d7 Doc: Add version and description to Qt-DBus documentation
This makes sure that the Qt version is part of the HTML title.

Pick-to: 6.2
Change-Id: I2ad8535a9289616d21c18bd9e92d4a91f6faced0
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2021-09-17 17:54:09 +02:00
Craig Scott
a37789e493 Revert "Ensure versionless wrappers do not introduce a new variable scope"
This reverts commit 08180e76e6.

Macros add another level of escaping that functions do not. The
conversion of the versionless wrappers to macros may alter the
behavior, so revert that change.

Task-number: QTBUG-96219
Pick-to: 6.2
Change-Id: Ic5dcff3081123d957888584ba1d76ae0580d9083
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-09-06 23:56:28 +10:00
Craig Scott
08180e76e6 Ensure versionless wrappers do not introduce a new variable scope
Using function instead of macro prevented the wrappers from being able
to pass back any variables set in the wrapped function. In some cases,
these variables were being explicitly passed back to the caller, but
that isn't needed if you just make each wrapper a macro. This also
makes things more future-proof because any newly introduced output
variables will work without having to update the wrappers.

Task-number: QTBUG-96121
Pick-to: 6.2
Change-Id: Ic4486de668694c06b47e466587b2cdcb969ea047
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-08-31 17:05:15 +10:00
David Faure
531b913f61 qdbuscpp2xml: add support for custom types with a new -t option
qdbuscpp2xml can't know about custom types registered with
qDBusRegisterMetaType<> in the server application whose header file
it's parsing. So add support for custom types using a command line
argument. For example:
    qdbuscpp2xml -t 'std::vector<Person>=a{ssss}' peopleserver.h
which generates
    <arg name="people" type="a{ssss}" direction="in"/>
    <annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="std::vector&lt;Person&gt;"/>

[ChangeLog][QtDBus][qdbuscpp2xml] Added a -t option to specify how to
handle custom types.

Change-Id: Ic0cad4f4eec8d5dfa48055c3a46cc772b1a60174
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-08-25 01:03:54 +02:00
David Faure
cf34fca4d0 QDBus: fix ExportScriptableInvokables to allow calling scriptable invokables
The "wantedMask" check in the xml generator didn't distinguish slots
from invokables, so exporting an object with just ExportScriptableInvokables
didn't allow calling Q_SCRIPTABLE methods.

Change-Id: I7b408755da5b28e67a9384d9df95e22dc5de2369
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-08-23 23:07:30 +02:00
Joerg Bornemann
c3308b13ca Doc: Add global \versionlessCMakeCommandsNote qdoc macro
When documenting a CMake command, document the unversioned command
'qt_foo' and use '\versionlessCMakeCommandNote qt6_foo' to refer to the
versioned command.  This avoids duplicating the command signature.

Use the new macro where applicable.

Pick-to: 6.2
Task-number: QTBUG-95796
Change-Id: I2e4180fbda0b89acf3d8c036459f591eb2f46475
Reviewed-by: Craig Scott <craig.scott@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-08-23 13:06:27 +02:00
Marc Mutz
ebee8a1336 QDBusMarshaller: fix -Wformat-overflow
Says GCC:

qdbusmarshaller.cpp: In member function ‘QDBusMarshaller* QDBusMarshaller::beginMap(QMetaType, QMetaType)’:
qdbusmarshaller.cpp:286:17: warning: ‘%s’ directive argument is null [-Wformat-overflow=]
  286 |         qWarning("QDBusMarshaller: type `%s' (%d) is not registered with D-BUS. "
      |                 ^

Fix by manual checking. It's a False Positive, because
QString::asprintf() can handle nullptr strings just find, but let's
make GCC happy.

Since the code snippet appears multiple times, even though GCC only
warns about one of them, take this opportunity to factor the code out
into a cold helper function.

Change-Id: I1d642f2465f34b670b179646185cba05cb16e573
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-07-08 01:49:26 +02:00
Alexey Edelev
b10e4e846e Migrate to autogenerated cpp exports
Replace the hardcoded cpp exports with a generated one where it's
applicable.

Task-number: QTBUG-90492
Change-Id: Idc160b594987b2c765e75bd669aae851b4366282
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-06-25 19:33:12 +02:00
David Faure
831aea1ce1 qdbus: add support for "aay" (QByteArrayList)
(I wish these common mappings were centralized though, so that
annotations in the XML file wouldn't be needed)

Pick-to: 6.0 6.1 5.15
Change-Id: Ie3e8731e44b6e0338c8a044408c34160cf0a3a1e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-05-02 22:00:43 +02:00
Andreas Buhr
dd24b61d35 Port QDBusServiceWatcher::watchedServices to bindable properties
Fixes: QTBUG-92993
Change-Id: I379c67c75bc536e387889de5303b01aef9399fcd
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2021-04-28 16:59:53 +02:00
Andreas Buhr
97a8727f0e Port of QDBusServiceWatcher::watchMode to new property system
Port watchMode in QDBusServiceWatcher to the new property
system. This is the easiest part.

Task-number: QTBUG-85520
Change-Id: I588212af205e77765862b8fecdbdcbf871717142
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-04-19 15:18:46 +02:00
Fabian Kosmale
cb43aaca11 Introduce QMetaObject::metaType
This function returns the metatype corresponding to the metaobject, or
an invalid metatype for namespaces.

This works as follows: First we increment the metaobject revision for
new metaobjects. Metaobjects with older revisions are handled by doing a
lookup by name. That fallback is also used for dynamic metaobjects (from
QtDBUS and those created by QMetaObjectBuilder).
For new metaobjects, we store the metatype in its metatype array, behind
the property metatypes. This avoids any changes to the property and
method metatype extraction logic: For properties, the metatype access
does not change, as the new metatype is after their metatypes. For
method metatypes, we already have an indirection layer (using offsets),
so by adjusting those offsets by one, the same logic keeps working.

To distinguish between namespaces and dynamic metaobjects, namespaces
store the metatypeinterface pointer for void in the metatype array,
whereas dynamic metaobjects store a nullptr.

One nice additional benefit is that this simplifies the generator logic
in moc, as the metatype array is now never empty.

Task-number: QTBUG-92077
Change-Id: Id3f920f28553f12032a71a1a87dad29e5374dbe7
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2021-03-25 17:33:07 +01:00
Paul Wicking
5fa8f5df7b Doc: Change section titles that cause bad links
Section titles are valid targets for QDoc's autolinker. When
they are identical to other valid link targets, such as for
example a class, these sections may cause invalid links.

Pick-to: 6.0 6.1
Fixes: QTBUG-91141
Change-Id: Ie9a6258d2bf83932335976d8c0b5fc59f2028ae5
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2021-03-11 15:01:35 +01:00
Nico Vertriest
3fa50b7b41 Doc: Fix warnings about wrong snippet path or missing .pro file
Task-number: QTBUG-91147
Change-Id: I6a55b2b713dd70cf1cbb0b93a8d4152e175e2c4d
Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
2021-02-19 14:04:21 +01:00
Alex Blasche
9828559a3d Several fixes to porting guides
Change-Id: I46b1754103d33d21e6cdeb338e3c6e3b0d0a4e29
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-02-10 10:39:06 +01:00
Joerg Bornemann
04f11f9935 Remove .prev_CMakeLists.txt files
Those serve no purpose anymore, now that the .pro files are gone.

Task-number: QTBUG-88742
Change-Id: I39943327b8c9871785b58e9973e4e7602371793e
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
2021-01-12 20:59:13 +01:00
David Skoland
9e09677c1d Remove QtDBus includes
Per the discussion of QTBUG-88831, we determined that module-wide
imports are unfortunate, especially for compile times. Following this,
all QtDBus includes have been replaced with the headers for the classes
actually used in each file. Additionally, some cleanup of header file
order and format has been performed in the changed files.

Pick-to: 6.0
Change-Id: I62c1b75682a48422f0ba1168dd5d7bd0952808ac
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-01-12 09:19:27 +01:00
Joerg Bornemann
ad2da2d27a Remove the qmake project files
Remove the qmake project files for most of Qt.

Leave the qmake project files for examples, because we still test those
in the CI to ensure qmake does not regress.

Also leave the qmake project files for utils and other minor parts that
lack CMake project files.

Task-number: QTBUG-88742
Change-Id: I6cdf059e6204816f617f9624f3ea9822703f73cc
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
2021-01-07 15:32:28 +01:00
Marc Mutz
105a66e654 Use (new) erase()/erase_if() algorithms
Change-Id: I45c18fd45c20b226e44d16315e3ebb6c305d4ab0
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-12-05 00:47:44 +01:00
Kai Koehne
130b209014 Doc: Use explicit linkage with target_link_libraries
The Professional CMake book suggests always using explicit linkage with
target_link_libraries, so let's use that.

Whether to use PUBLIC or PRIVATE depends on the context. But let's
be conservative and advise on using PRIVATE by default.

Task-number: QTBUG-88935
Pick-to: 6.0
Change-Id: I12b80ee85be9f6916f1e4dea6b1c9cb29e03c20f
Reviewed-by: Craig Scott <craig.scott@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-11-30 05:39:21 +01:00
Giuseppe D'Angelo
612a01be65 Deprecate QScopedPointer::take()
We've decided that QScopedPointer shouldn't be movable,
because it would break the semantics of being "scoped"
(the pointer/pointee won't survive the scope).

Then, QScopedPointer shouldn't allow for take() either.
If you need those semantics, reach for unique_ptr.

[ChangeLog][QtCore][QScopedPointer] The take() function
has been deprecated. This was an API mistake, as it
allowed the pointer/pointee to escape from the scope,
defeating the point of the QScopedPointer class. If you
need such semantics, use std::unique_ptr (and call
release()).

Change-Id: I3236f085f763b04eb98e3242abc06f7c54fb3d8b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-11-20 14:28:31 +01:00
Robert Griebl
2fab1971fe Fix memory corruption in QDBusInterface signal emissions
If more than one signal parameter required conversions (e.g. 2
QVariantMaps), then the auxParameter list would be reallocated on the
second append. This resulted in the reference to the first conversion
(stored in params) to be broken.

Found with valgrind after the QtApplicationManager started crashing
weirdly when built against Qt 6. The same code is in Qt 5, but it
just works fine there: I guess the reallocation strategy in QList is
different there, so we never have to reallocate the list.

Change-Id: I2e0c8906ebc9474c4ec9f53cafc1689003d5c4c5
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-11-19 12:28:44 +01:00
Jerome Pasion
d4b3989818 Update landing pages and module pages in qtbase
-Qt SQL, Qt D-BUS, Qt GUI, Qt OpenGL, Qt Widgets,
 Qt Test, Qt Concurrent, Qt XML, Qt Network, Qt Core
-language edits for consistency, add links

Task-number: QTBUG-87155
Change-Id: Ic61350c9fa15090c802a42d8e9116219591eba73
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2020-11-17 20:16:12 +01:00
Topi Reinio
d01b9ac6af Doc: Add missing brief statements for \property documentation
... where applicable.

Fixes: QTBUG-88232
Change-Id: I835df434765caededd35d5114965b4a1663e7942
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2020-11-12 06:54:53 +01:00
Karsten Heimrich
15f55e9be5 Doc: Add Qt6 QDBus porting guide
Fixes: QTBUG-88027
Change-Id: Ic4fa2070aa7068a1d0ff02d43aa6a3d1d10db0d7
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-11-11 12:48:21 +01:00
Jerome Pasion
3553f8119b Rename "Porting" pages to "Changes"
The content in the porting guides are closer to a changelog than
a porting guide. At this point, it is easier for maintainers and
contributors to write in a changelog than a guide. This change
should help with readability and is closer to the usage of
"Changes" in documentation.

Part of a rename in other submodules.

Task-number: QTBUG-87156
Change-Id: Ib59de7976fae19e7b39962e80161df6628e4070b
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2020-11-09 16:01:33 +01:00
Kai Koehne
504647a28f CMake: Update documentation of CMake commands for Qt 6 for DBus
Change-Id: Iec86b42a0a1b52ea4688226f3c71fc2bfc6d48ac
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-11-08 14:14:23 +02:00
Kai Koehne
8040d3dce1 Doc: Prefer versioned CMake library targets
The non-versioned one's do miss some properties. It's therefore best
to not advocate using them.

Change-Id: I53645e65ed4de4e0100e59905c024cdfe40be0c5
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-11-01 15:58:13 +01:00
Topi Reinio
ae347b23d6 Doc: Fix links to the CMake manual
Task-number: QTBUG-86295
Change-Id: I7b2208284d65ec9182352490bd4c92458c5e5e37
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2020-10-30 06:18:49 +01:00
Kai Koehne
66c94b8356 CMake: Document versionless variants for CMake commands for DBus
Pick-to: 5.15
Change-Id: I7168a2d2589ef72d6e6f4bc568c5a914faa777df
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2020-10-25 10:49:59 +02:00
Lars Knoll
11bad61096 Deprecate QVariant::Type
It's been obsolete for a long time already. Make sure
the compiler now warns about it and remove all remaining
uses in qtbase.

Change-Id: I0ff80311184dba52d2ba5f4e2fabe0d47fdc59d7
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-10-23 09:58:57 +02:00
Lars Knoll
4175175588 Rename the QMetaType::MovableType flag to RelocatableType
Keep this in sync with the changes we have done in QTypeInfo.

Change-Id: Iaacb0f3cc5c46d3486084a1f6eca480a233d5e1a
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-10-23 09:49:36 +02:00
Volker Hilsheimer
58060e7b6b Fix qdoc warnings in QtDBus
And remove the limitation to 8 types from the documentation.

Change-Id: I92c67368e53d69fd851886c621f3f894f638bae9
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-10-21 07:31:26 +02:00
Giuseppe D'Angelo
35c565e965 Port some more /*implicit*/-like comments to Q_IMPLICIT
Change-Id: Ib70ad3f29365153af647deea54fc45467c413cb9
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-10-16 01:07:31 +02:00
Lars Knoll
92b7122eda Remove dead code
This code has been deprecated in Qt 5.

Change-Id: Ia8e0bc791ac1f43df7124b4f30db3d0bb9966015
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2020-10-12 14:49:50 +02:00
Allan Sandfeld Jensen
564b59d903 Another round of replacing 0 with nullptr
This time based on grepping to also include documentation, tests and
examples previously missed by the automatic tool.

Change-Id: Ied1703f4bcc470fbc275f759ed5b7c588a5c4e9f
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2020-10-07 23:02:47 +02:00
Allan Sandfeld Jensen
93dad2bf91 Switch Q_DECL_DEPRECATED to use C++14 [[deprecated]]
As a C++ attribute it must be on the beginning of the line or after
the function name however. And for friend declarations can only
be on the definition.

Change-Id: I456884428f36e1f1c621089c7b1addee13ada0fe
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-10-03 00:12:05 +02:00
Allan Sandfeld Jensen
cc692bb58c Get rid of some #ifdef qt6
None of this code is even compiled in qt6.

Change-Id: I5891cc9459320083ad3908fcbf646f3ba75b8a4d
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-09-30 21:15:40 +02:00
Lars Knoll
850d850c5a Use QMetaType instead of integer based type ids
Change the implementation of Qt DBus to use QMetaType directly
instead of integer based type ids.

Change-Id: I999023b58fa50dcc3504386467faf09874f7d2cf
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-09-23 19:30:28 +02:00
Lars Knoll
be714154fa Use a hash to store the DBus marshalling data
A QList<int> where int is the metaType id is a bad idea in Qt 6,
as custom types will start at index 65536. Use a QHash instead.

Also fix the API to use QMetaType as arguments and return values.

Change-Id: Ia0b894126271be1f01dc4593b5155fb75d713720
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-09-23 19:30:22 +02:00
Lars Knoll
d39bd9e258 Cleanup DBus type registration code
Modernize the code base, use QMetaType and avoid
reinterpret_casts.

Change-Id: I0bad2ee393a0f850cf40b248cb9439b06ed9f663
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-09-23 19:30:15 +02:00
Lars Knoll
abd1b7f306 Cleanup QDBusPendingReply
Remove the limitation of max 8 arguments and clean up the
template code.

This required a bit of special work to ensure
QDBusPendingReply<void> works the same way
as QDBusPendingReply<>.

Change-Id: I8e822b2f97f0712746b917056ea8f3d5c219c7f6
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-09-23 19:30:10 +02:00
Alexandru Croitor
403213240c CMake: Regenerate projects to use new qt_internal_ API
Modify special case locations to use the new API as well.
Clean up some stale .prev files that are not needed anymore.
Clean up some project files that are not used anymore.

Task-number: QTBUG-86815
Change-Id: I9947da921f98686023c6bb053dfcc101851276b5
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2020-09-23 16:59:06 +02:00
Kevin Funk
e59e924f52 dbus: Skip AUTOUIC on generated sources
Skip AUTOUIC on sources generated by the qt_add_dbus_interface and
qt_add_dbus_adaptor macros. Otherwise CMake will warn due to policy
CMP0071:

```
  For compatibility, CMake is excluding the GENERATED source file(s):

  (...)

  from processing by AUTOMOC and AUTOUIC. (...)
```

Pick-to: 5.15
Change-Id: I7d14b23c9343940964d5bc0d1d18fc19b41b5cd0
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-09-21 13:18:24 +02:00
Nico Vertriest
169f332eab Doc: Correct link errors qtbase
Task-number: QTBUG-86295
Change-Id: I27f6bbdadffb08a8794520a14dfe0e2334979575
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2020-09-21 08:17:41 +02:00
Paul Wicking
465ddfc870 Doc: Add links to Qt 6 changes files from module index
Task-number: QTBUG-84051
Change-Id: Iac25df135c9d73a990b41243e08cd38ea78296a4
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
2020-09-18 09:59:38 +02:00
Paul Wicking
c5f611c084 Doc: Add porting guide documents
Also add existing such docs to the new document group

Task-number: QTBUG-84051
Change-Id: I76f033f0846e09943f249d2beeb1606869eef382
Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
2020-09-16 18:32:09 +02:00
Lars Knoll
ead02871cc Remove some dead code
Change-Id: I9d67eaa1b9d32ca245cf606ca2f11c77dafac1df
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-09-12 23:36:50 +02:00
Lars Knoll
57f48eea48 Remove two comments that don't make any sense
Change-Id: I775a81c4e3c0fb3d7eebf403bffb1e82864eff48
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-09-12 23:36:45 +02:00