Merge remote-tracking branch 'origin/4.11'

Change-Id: I65ce6aa917219a8f8b91b48c7077f8097248375c
This commit is contained in:
Orgad Shaneh
2020-02-05 18:36:07 +02:00
6 changed files with 156 additions and 141 deletions

View File

@@ -56,7 +56,8 @@ depends += qtwidgets \
qtsensors \
qtuitools \
qtwebkit \
qtxml
qtxml \
qttestlib
include(../../config/macros.qdocconf)
include(../../config/qt-cpp-ignore.qdocconf)

View File

@@ -31,33 +31,36 @@
/*!
\namespace Aggregation
\brief The Aggregation namespace contains support for bundling related components,
such that each component exposes the properties and behavior of the
so that each component exposes the properties and behavior of the
other components to the outside.
Components that are bundled to an Aggregate can be "cast" to each other
Components that are bundled into an aggregate can be \e cast to each other
and have a coupled life cycle. See the documentation of Aggregation::Aggregate for
details and examples.
*/
/*!
\class Aggregation::Aggregate
\mainclass
\ingroup mainclasses
\threadsafe
\brief The Aggregate class defines a collection of related components that
can be viewed as a unit.
An Aggregate is a collection of components that are handled as a unit,
An aggregate is a collection of components that are handled as a unit,
such that each component exposes the properties and behavior of the
other components in the Aggregate to the outside.
other components in the aggregate to the outside.
Specifically that means:
\list
\li They can be "cast" to each other (using query and query_all functions).
\li Their life cycle is coupled, i.e. whenever one is deleted all of them are.
\li They can be \e cast to each other (using query() and query_all()
functions).
\li Their life cycle is coupled. That is, whenever one is deleted, all of
them are.
\endlist
Components can be of any QObject derived type.
You can use an Aggregate to simulate multiple inheritance by aggregation. Assume we have
You can use an aggregate to simulate multiple inheritance by aggregation.
Assuming we have the following code:
\code
using namespace Aggregation;
class MyInterface : public QObject { ........ };
@@ -65,21 +68,21 @@
[...]
MyInterface *object = new MyInterface; // this is single inheritance
\endcode
The query function works like a qobject_cast with normal objects:
The query function works like a qobject_cast() with normal objects:
\code
Q_ASSERT(query<MyInterface>(object) == object);
Q_ASSERT(query<MyInterfaceEx>(object) == 0);
\endcode
If we want 'object' to also implement the class MyInterfaceEx,
If we want \c object to also implement the class \c MyInterfaceEx,
but don't want to or cannot use multiple inheritance, we can do it
at any point using an Aggregate:
at any point using an aggregate:
\code
MyInterfaceEx *objectEx = new MyInterfaceEx;
Aggregate *aggregate = new Aggregate;
aggregate->add(object);
aggregate->add(objectEx);
\endcode
The Aggregate bundles the two objects together.
The aggregate bundles the two objects together.
If we have any part of the collection we get all parts:
\code
Q_ASSERT(query<MyInterface>(object) == object);
@@ -87,25 +90,24 @@
Q_ASSERT(query<MyInterface>(objectEx) == object);
Q_ASSERT(query<MyInterfaceEx>(objectEx) == objectEx);
\endcode
The following deletes all three: object, objectEx and aggregate:
The following deletes all three: \c object, \c objectEx and \c aggregate:
\code
delete objectEx;
// or delete object;
// or delete aggregate;
\endcode
Aggregation aware code never uses qobject_cast, but always uses
Aggregation::query which behaves like a qobject_cast as a fallback.
Aggregation-aware code never uses qobject_cast(). It always uses
Aggregation::query(), which behaves like a qobject_cast() as a fallback.
*/
/*!
\fn T *Aggregate::component()
Template function that returns the component with the given type, if there is one.
If there are multiple components with that type a random one is returned.
If there are multiple components with that type, a random one is returned.
\sa Aggregate::components()
\sa Aggregate::add()
\sa Aggregate::components(), add()
*/
/*!
@@ -113,8 +115,7 @@
Template function that returns all components with the given type, if there are any.
\sa Aggregate::component()
\sa Aggregate::add()
\sa Aggregate::component(), add()
*/
/*!
@@ -131,10 +132,10 @@
\relates Aggregation::Aggregate
\fn T *Aggregation::query<T *>(QObject *obj)
Performs a dynamic cast that is aware of a possible Aggregate that \a obj
might belong to. If \a obj itself is of the requested type then it is simply cast
and returned. Otherwise, if \a obj belongs to an Aggregate all its components are
checked, or if it doesn't belong to an Aggregate null is returned.
Performs a dynamic cast that is aware of a possible aggregate that \a obj
might belong to. If \a obj itself is of the requested type, it is simply cast
and returned. Otherwise, if \a obj belongs to an aggregate, all its components are
checked. If it doesn't belong to an aggregate, null is returned.
\sa Aggregate::component()
*/
@@ -143,18 +144,25 @@
\relates Aggregation::Aggregate
\fn QList<T *> Aggregation::query_all<T *>(QObject *obj)
If \a obj belongs to an Aggregate, all components that can be cast to the given
If \a obj belongs to an aggregate, all components that can be cast to the given
type are returned. Otherwise, \a obj is returned if it is of the requested type.
\sa Aggregate::components()
*/
/*!
\fn void Aggregation::Aggregate::changed()
This signal is emitted when a component is added to or removed from an
aggregate.
\sa add(), remove()
*/
using namespace Aggregation;
/*!
\fn Aggregate *Aggregate::parentAggregate(QObject *obj)
Returns the Aggregate object of \a obj if there is one. Otherwise returns 0.
Returns the aggregate object of \a obj if there is one. Otherwise returns 0.
*/
Aggregate *Aggregate::parentAggregate(QObject *obj)
{
@@ -169,7 +177,6 @@ QHash<QObject *, Aggregate *> &Aggregate::aggregateMap()
}
/*!
\fn QReadWriteLock &Aggregate::lock()
\internal
*/
QReadWriteLock &Aggregate::lock()
@@ -179,10 +186,8 @@ QReadWriteLock &Aggregate::lock()
}
/*!
\fn Aggregate::Aggregate(QObject *parent)
Creates a new Aggregate with the given \a parent.
The \a parent is passed directly passed to the QObject part
Creates a new aggregate with the given \a parent.
The parent is directly passed to the QObject part
of the class and is not used beside that.
*/
Aggregate::Aggregate(QObject *parent)
@@ -193,8 +198,6 @@ Aggregate::Aggregate(QObject *parent)
}
/*!
\fn Aggregate::~Aggregate()
Deleting the aggregate automatically deletes all its components.
*/
Aggregate::~Aggregate()
@@ -224,13 +227,11 @@ void Aggregate::deleteSelf(QObject *obj)
}
/*!
\fn void Aggregate::add(QObject *component)
Adds the \a component to the aggregate.
You can't add a component that is part of a different aggregate
You cannot add a component that is part of a different aggregate
or an aggregate itself.
\sa Aggregate::remove()
\sa remove()
*/
void Aggregate::add(QObject *component)
{
@@ -253,11 +254,9 @@ void Aggregate::add(QObject *component)
}
/*!
\fn void Aggregate::remove(QObject *component)
Removes the \a component from the aggregate.
\sa Aggregate::add()
\sa add()
*/
void Aggregate::remove(QObject *component)
{

View File

@@ -30,22 +30,20 @@
/*!
\class ExtensionSystem::IPlugin
\mainclass
\ingroup mainclasses
\brief The IPlugin class is the base class for all plugins.
The IPlugin class is an abstract class that must be implemented
once for each plugin.
A plugin consists of two parts: A description file, and a library
A plugin consists of two parts: a description file, and a library
that at least contains the IPlugin implementation.
\tableofcontents
\section1 Plugin Specification
A plugin needs to provide a plugin specification file in addition
to the actual plugin library, so the plugin manager can find the plugin,
resolve its dependencies, and load it. For more information,
see \l{Plugin Specifications}.
see \l{Plugin Meta Data}.
\section1 Plugin Implementation
Plugins must provide one implementation of the IPlugin class, located
@@ -65,7 +63,7 @@
needed by other plugins and register them via appropriate core functions
or, if a weak dependency is neceessary to be implemented, to put
them into the global object pool.
\li All plugins' extensionsInitialized functions are called in \e{leaf-to-root}
\li All plugins' extensionsInitialized() functions are called in \e{leaf-to-root}
order of the dependency tree. At this point, plugins can
be sure that all plugins that depend on this plugin have
been initialized completely and objects these plugins wish to
@@ -75,17 +73,31 @@
that depend on that plugin also fail.
*/
/*!
\enum IPlugin::ShutdownFlag
This enum type holds whether the plugin is shut down synchronously or
asynchronously.
\value SynchronousShutdown
The plugin is shut down synchronously.
\value AsynchronousShutdown
The plugin needs to perform asynchronous
actions before it shuts down.
*/
/*!
\fn bool IPlugin::initialize(const QStringList &arguments, QString *errorString)
\brief Called after the plugin has been loaded and the IPlugin instance
Called after the plugin has been loaded and the IPlugin instance
has been created.
The initialize functions of plugins that depend
on this plugin are called after the initialize function of this plugin
has been called. Plugins should initialize their internal state in this
function. Returns if initialization of successful. If it wasn't successful,
the \a errorString should be set to a user-readable message
describing the reason.
The initialize functions of plugins that depend on this plugin are called
after the initialize function of this plugin has been called with
\a arguments. Plugins should initialize their internal state in this
function.
Returns whether initialization succeeds. If it does not, \a errorString
should be set to a user-readable message describing the reason.
\sa extensionsInitialized()
\sa delayedInitialize()
@@ -93,12 +105,12 @@
/*!
\fn void IPlugin::extensionsInitialized()
\brief Called after the IPlugin::initialize() function has been called,
and after both the IPlugin::initialize() and IPlugin::extensionsInitialized()
Called after the initialize() function has been called,
and after both the initialize() and \c extensionsInitialized()
functions of plugins that depend on this plugin have been called.
In this function, the plugin can assume that plugins that depend on
this plugin are fully 'up and running'. It is a good place to
this plugin are fully \e {up and running}. It is a good place to
look in the global object pool for objects that have been provided
by weakly dependent plugins.
@@ -108,19 +120,21 @@
/*!
\fn bool IPlugin::delayedInitialize()
\brief Called after all plugins' IPlugin::extensionsInitialized() function has been called,
and after the IPlugin::delayedInitialize() function of plugins that depend on this plugin
have been called.
Called after all plugins' extensionsInitialized() function has been called,
and after the \c delayedInitialize() function of plugins that depend on this
plugin have been called.
The plugins' delayedInitialize() functions are called after the application is already running,
with a few milliseconds delay to application startup, and between individual delayedInitialize
function calls. To avoid unnecessary delays, a plugin should return true from the function if it
actually implements it, to indicate that the next plugins' delayedInitialize() call should
be delayed a few milliseconds to give input and paint events a chance to be processed.
The plugins' \c delayedInitialize() functions are called after the
application is already running, with a few milliseconds delay to
application startup, and between individual \c delayedInitialize()
function calls. To avoid unnecessary delays, a plugin should return
\c true from the function if it actually implements it, to indicate
that the next plugins' \c delayedInitialize() call should be delayed
a few milliseconds to give input and paint events a chance to be processed.
This function can be used if a plugin needs to do non-trivial setup that doesn't
necessarily need to be done directly at startup, but still should be done within a
short time afterwards. This can decrease the felt plugin/application startup
short time afterwards. This can decrease the perceived plugin or application startup
time a lot, with very little effort.
\sa initialize()
@@ -129,7 +143,7 @@
/*!
\fn IPlugin::ShutdownFlag IPlugin::aboutToShutdown()
\brief Called during a shutdown sequence in the same order as initialization
Called during a shutdown sequence in the same order as initialization
before the plugins get deleted in reverse order.
This function should be used to disconnect from other plugins,
@@ -138,34 +152,44 @@
it needs to wait for external processes to finish for a clean shutdown,
the plugin can return IPlugin::AsynchronousShutdown from this function. This
will keep the main event loop running after the aboutToShutdown() sequence
has finished, until all plugins requesting AsynchronousShutdown have sent
has finished, until all plugins requesting asynchronous shutdown have sent
the asynchronousShutdownFinished() signal.
The default implementation of this function does nothing and returns
IPlugin::SynchronousShutdown.
Returns IPlugin::AsynchronousShutdown if the plugin needs to perform
asynchronous actions before performing the shutdown.
asynchronous actions before shutdown.
\sa asynchronousShutdownFinished()
*/
/*!
\fn QObject *IPlugin::remoteCommand(const QStringList &options, const QStringList &arguments)
\brief When \QC is executed with the -client argument while already another instance of \QC
is running, this function of plugins is called in the running instance.
\fn QObject *IPlugin::remoteCommand(const QStringList &options,
const QString &workingDirectory,
const QStringList &arguments)
When \QC is executed with the \c -client argument while another \QC instance
is running, this function of the plugin is called in the running instance.
The \a workingDirectory argument specifies the working directory of the
calling process. For example, if you're in a directory, and you execute
\c { qtcreator -client file.cpp}, the working directory of the calling
process is passed to the running instance and \c {file.cpp} is transformed
into an absolute path starting from this directory.
Plugin-specific arguments are passed in \a options, while the rest of the
arguments are passed in \a arguments.
\returns a QObject that blocks the command until it is destroyed, if -block is used.
Returns a QObject that blocks the command until it is destroyed, if \c -block
is used.
\sa PluginManager::serializedArguments()
*/
/*!
\fn void IPlugin::asynchronousShutdownFinished()
Sent by the plugin implementation after a asynchronous shutdown
Sent by the plugin implementation after an asynchronous shutdown
is ready to proceed with the shutdown sequence.
\sa aboutToShutdown()
@@ -174,7 +198,6 @@
using namespace ExtensionSystem;
/*!
\fn IPlugin::IPlugin()
\internal
*/
IPlugin::IPlugin()
@@ -183,7 +206,6 @@ IPlugin::IPlugin()
}
/*!
\fn IPlugin::~IPlugin()
\internal
*/
IPlugin::~IPlugin()
@@ -193,11 +215,10 @@ IPlugin::~IPlugin()
}
/*!
\fn QVector<QObject *> IPlugin::createTestObjects() const
Returns objects that are meant to be passed on to \l QTest::qExec().
Returns objects that are meant to be passed on to QTest::qExec().
This function will be called if the user starts \QC with '-test PluginName' or '-test all'.
This function will be called if the user starts \QC with
\c {-test PluginName} or \c {-test all}.
The ownership of returned objects is transferred to caller.
*/
@@ -207,7 +228,6 @@ QVector<QObject *> IPlugin::createTestObjects() const
}
/*!
\fn PluginSpec *IPlugin::pluginSpec() const
Returns the PluginSpec corresponding to this plugin.
This is not available in the constructor.
*/

View File

@@ -89,7 +89,7 @@ enum { debugLeaks = 0 };
/*!
\class ExtensionSystem::PluginManager
\mainclass
\ingroup mainclasses
\brief The PluginManager class implements the core plugin system that
manages the plugins, their life cycle, and their registered objects.
@@ -97,13 +97,13 @@ enum { debugLeaks = 0 };
The plugin manager is used for the following tasks:
\list
\li Manage plugins and their state
\li Manipulate a 'common object pool'
\li Manipulate a \e {common object pool}
\endlist
\section1 Plugins
Plugins consist of an XML descriptor file, and of a library that contains a Qt plugin
that must derive from the IPlugin class and has an IID of
Plugins must derive from the IPlugin class and have the IID
\c "org.qt-project.Qt.QtCreatorPlugin".
The plugin manager is used to set a list of file system directories to search for
plugins, retrieve information about the state of these plugins, and to load them.
@@ -114,22 +114,22 @@ enum { debugLeaks = 0 };
PluginManager::setPluginPaths(QStringList("plugins"));
PluginManager::loadPlugins(); // try to load all the plugins
\endcode
Additionally, it is possible to directly access the plugin specifications
(the information in the descriptor file), the plugin instances (via PluginSpec),
and their state.
Additionally, it is possible to directly access plugin meta data, instances,
and state.
\section1 Object Pool
Plugins (and everybody else) can add objects to a common 'pool' that is located in
Plugins (and everybody else) can add objects to a common \e pool that is located in
the plugin manager. Objects in the pool must derive from QObject, there are no other
prerequisites. Objects can be retrieved from the object pool via the getObject()
and getObjectByName() functions.
Whenever the state of the object pool changes a corresponding signal is emitted by the plugin manager.
Whenever the state of the object pool changes, a corresponding signal is
emitted by the plugin manager.
A common usecase for the object pool is that a plugin (or the application) provides
an "extension point" for other plugins, which is a class / interface that can
an \e {extension point} for other plugins, which is a class or interface that can
be implemented and added to the object pool. The plugin that provides the
extension point looks for implementations of the class / interface in the object pool.
extension point looks for implementations of the class or interface in the object pool.
\code
// Plugin A provides a "MimeTypeHandler" extension point
// in plugin B:
@@ -141,15 +141,15 @@ enum { debugLeaks = 0 };
\endcode
The \c{ExtensionSystem::Invoker} class template provides "syntactic sugar"
for using "soft" extension points that may or may not be provided by an
object in the pool. This approach does neither require the "user" plugin being
linked against the "provider" plugin nor a common shared
The ExtensionSystem::Invoker class template provides \e {syntactic sugar}
for using \e soft extension points that may or may not be provided by an
object in the pool. This approach neither requires the \e user plugin being
linked against the \e provider plugin nor a common shared
header file. The exposed interface is implicitly given by the
invokable functions of the "provider" object in the object pool.
invokable functions of the provider object in the object pool.
The \c{ExtensionSystem::invoke} function template encapsulates
{ExtensionSystem::Invoker} construction for the common case where
The ExtensionSystem::invoke() function template encapsulates
ExtensionSystem::Invoker construction for the common case where
the success of the call is not checked.
\code
@@ -205,35 +205,18 @@ enum { debugLeaks = 0 };
is deduced from the parameters themselves and must match the type of
the arguments of the called functions \e{exactly}. No conversion or even
integer promotions are applicable, so to invoke a function with a \c{long}
parameter explicitly use \c{long(43)} or such.
parameter explicitly, use \c{long(43)} or such.
\note The object pool manipulating functions are thread-safe.
*/
/*!
\fn void PluginManager::objectAdded(QObject *obj)
Signals that \a obj has been added to the object pool.
*/
/*!
\fn void PluginManager::aboutToRemoveObject(QObject *obj)
Signals that \a obj will be removed from the object pool.
*/
/*!
\fn void PluginManager::pluginsChanged()
Signals that the list of available plugins has changed.
\sa plugins()
*/
/*!
\fn T *PluginManager::getObject()
Retrieves the object of a given type from the object pool.
This function uses \c qobject_cast to determine the type of an object.
If there are more than one object of the given type in
If there are more than one objects of the given type in
the object pool, this function will arbitrarily choose one of them.
\sa addObject()
@@ -293,10 +276,10 @@ PluginManager::~PluginManager()
Adds the object \a obj to the object pool, so it can be retrieved
again from the pool by type.
The plugin manager does not do any memory management - added objects
The plugin manager does not do any memory management. Added objects
must be removed from the pool and deleted manually by whoever is responsible for the object.
Emits the objectAdded() signal.
Emits the \c objectAdded() signal.
\sa PluginManager::removeObject()
\sa PluginManager::getObject()
@@ -308,7 +291,8 @@ void PluginManager::addObject(QObject *obj)
}
/*!
Emits aboutToRemoveObject() and removes the object \a obj from the object pool.
Emits the \c aboutToRemoveObject() signal and removes the object \a obj
from the object pool.
\sa PluginManager::addObject()
*/
void PluginManager::removeObject(QObject *obj)
@@ -328,6 +312,9 @@ QVector<QObject *> PluginManager::allObjects()
return d->allObjects;
}
/*!
\internal
*/
QReadWriteLock *PluginManager::listLock()
{
return &d->m_lock;
@@ -347,7 +334,7 @@ void PluginManager::loadPlugins()
}
/*!
Returns true if any plugin has errors even though it is enabled.
Returns \c true if any plugin has errors even though it is enabled.
Most useful to call after loadPlugins().
*/
bool PluginManager::hasError()
@@ -455,9 +442,8 @@ QStringList PluginManager::pluginPaths()
}
/*!
Sets the plugin search paths, i.e. the file system paths where the plugin manager
looks for plugin descriptions. All given \a paths and their sub directory trees
are searched for plugin xml description files.
Sets the plugin paths. All the specified \a paths and their subdirectory
trees are searched for plugins.
\sa pluginPaths()
\sa loadPlugins()
@@ -478,11 +464,14 @@ QString PluginManager::pluginIID()
}
/*!
Sets the IID that valid plugins must have. Only plugins with this IID are loaded, others are
silently ignored.
Sets the IID that valid plugins must have to \a iid. Only plugins with this
IID are loaded, others are silently ignored.
At the moment this must be called before setPluginPaths() is called.
\omit
// ### TODO let this + setPluginPaths read the plugin meta data lazyly whenever loadPlugins() or plugins() is called.
\endomit
*/
void PluginManager::setPluginIID(const QString &iid)
{
@@ -490,7 +479,7 @@ void PluginManager::setPluginIID(const QString &iid)
}
/*!
Defines the user specific settings to use for information about enabled and
Defines the user specific \a settings to use for information about enabled and
disabled plugins.
Needs to be set before the plugin search path is set with setPluginPaths().
*/
@@ -500,7 +489,7 @@ void PluginManager::setSettings(QSettings *settings)
}
/*!
Defines the global (user-independent) settings to use for information about
Defines the global (user-independent) \a settings to use for information about
default disabled plugins.
Needs to be set before the plugin search path is set with setPluginPaths().
*/
@@ -552,10 +541,10 @@ QStringList PluginManager::argumentsForRestart()
}
/*!
List of all plugin specifications that have been found in the plugin search paths.
List of all plugins that have been found in the plugin search paths.
This list is valid directly after the setPluginPaths() call.
The plugin specifications contain the information from the plugins' xml description files
and the current state of the plugins. If a plugin's library has been already successfully loaded,
The plugin specifications contain plugin metadata and the current state
of the plugins. If a plugin's library has been already successfully loaded,
the plugin specification has a reference to the created plugin instance as well.
\sa setPluginPaths()
@@ -631,7 +620,7 @@ static QStringList subList(const QStringList &in, const QString &key)
and passes them on to the respective plugins along with the arguments.
\a socket is passed for disconnecting the peer when the operation is done (for example,
document is closed) for supporting the -block flag.
document is closed) for supporting the \c -block flag.
*/
void PluginManager::remoteArguments(const QString &serializedArgument, QObject *socket)
@@ -659,13 +648,17 @@ void PluginManager::remoteArguments(const QString &serializedArgument, QObject *
/*!
Takes the list of command line options in \a args and parses them.
The plugin manager itself might process some options itself directly (-noload <plugin>), and
adds options that are registered by plugins to their plugin specs.
The caller (the application) may register itself for options via the \a appOptions list, containing pairs
of "option string" and a bool that indicates if the option requires an argument.
The plugin manager itself might process some options itself directly
(\c {-noload <plugin>}), and adds options that are registered by
plugins to their plugin specs.
The caller (the application) may register itself for options via the
\a appOptions list, containing pairs of \e {option string} and a bool
that indicates whether the option requires an argument.
Application options always override any plugin's options.
\a foundAppOptions is set to pairs of ("option string", "argument") for any application options that were found.
\a foundAppOptions is set to pairs of (\e {option string}, \e argument)
for any application options that were found.
The command line options that were not processed can be retrieved via the arguments() function.
If an error occurred (like missing argument for an option that requires one), \a errorString contains
a descriptive message of the error.

View File

@@ -360,6 +360,8 @@ void ProjectTreeWidget::rowsInserted(const QModelIndex &parent, int start, int e
Node *ProjectTreeWidget::nodeForFile(const FilePath &fileName)
{
if (fileName.isEmpty())
return nullptr;
Node *bestNode = nullptr;
int bestNodeExpandCount = INT_MAX;