Skip to content

Conversation

@schnitzeltony
Copy link

SortFilterProxyModel is an awesome project. The only thing caused headaches to me should be fixed by this series.

  • Add build for shared library
  • Fix --as-needed / Q_COREAPP_STARTUP_FUNCTION
  • Update Readme

Comments welcome

SortFilterProxyModel is an awesome piece of code and we use it in several
projects. This is the reason for this patch introducing shared library support.
By doing so we:

* Save memory by using shared library - at least RAM when running multiple
  applications using SortFilterProxyModel
* Save build time: SortFilterProxyModel is build once for all

To remain compatible with previous behaviour user can select what to do by cmake
options:

BUILD_OBJECT_LIB:
(Default ON): Same as before: Add sources to your project and build obj-files
that can be linked to your binary. It was taken care that projects behaves same
as before (tested) - no need for develepers to make changes in their project.

BUILD_SHARED_LIB: Build and install a shared library so that other projects can
use it. This is the way packagers prefer deploying code.

Signed-off-by: Andreas Müller <schnitzeltony@gmail.com>
Now that SortFilterProxyModel can be build standalone, Qt-Creator creates
CMake.user.. files once it configures SortFilterProxyModel. User configurations
are nothing to be added to repository (accidentally) so add an entry in
.gitignore.

Signed-off-by: Andreas Müller <schnitzeltony@gmail.com>
This does not cause any change to build but it adds the headers to the file list
of IDEs like qt-creator gives developers much easier access.

Signed-off-by: Andreas Müller <schnitzeltony@gmail.com>
… --as-needed

There are build environments that link their binaries with --as-needed for good
reasons [1].

This causes trouble here too: The application linking against
SortFilterProxyModel has no reference to a symbol within SortFilterProxyModel
so the library will simply be skipped and not loaded at runtime causing:

| qrc:/qml/FaFilter.qml:2:1: module "SortFilterProxyModel" is not installed

Linker with --as-needed behave similar as linking against static libraries and
Qt documatation [2] warns explicitly not to use Q_COREAPP_STARTUP_FUNCTION when
linking against static libraries.

To get around a stateless class SortFilterProxyModel (luckily this name was not
used yet) was created, that just contains the static method registerQml(). To
avoid multile calls on environemts that do not link with --as-needed all
register functions ensure to be called once only by a variable wasRegistered.

In the following patch Readme.md will updated and will recommend highly to call
SortFilterProxyModel::registerQml() - who knows which environment your
application will be build in?

[1] https://wiki.gentoo.org/wiki/Project:Quality_Assurance/As-needed
[2] https://doc.qt.io/qt-5/qcoreapplication.html#Q_COREAPP_STARTUP_FUNCTION

Signed-off-by: Andreas Müller <schnitzeltony@gmail.com>
Signed-off-by: Andreas Müller <schnitzeltony@gmail.com>
@schnitzeltony
Copy link
Author

Ping?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant