diff options
author | Ingo Klöcker <[email protected]> | 2021-06-25 13:06:17 +0000 |
---|---|---|
committer | Ingo Klöcker <[email protected]> | 2021-06-28 09:56:12 +0000 |
commit | 3503816570a19352e4b8a81d1cd0f3a9337b8c55 (patch) | |
tree | e95680457136e47d15c33b09c301bf0987caa008 /lang/qt/src/job.cpp | |
parent | qt: Remove superfluous trailing ';' (diff) | |
download | gpgme-3503816570a19352e4b8a81d1cd0f3a9337b8c55.tar.gz gpgme-3503816570a19352e4b8a81d1cd0f3a9337b8c55.zip |
qt: Add mechanism for missing d-pointer in Job
* lang/qt/src/job_p.h: New.
* lang/qt/src/job.cpp (typedef JobPrivateHash, d_func, setJobPrivate,
getJobPrivate): New.
--
Because of ABI compatibility requirements we cannot add a d-pointer
to Job. Therefore we store the d-pointers in a global static. This
mechanism will allow Job subclasses to store additional data without
breaking the ABI.
GnuPG-bug-id: 4717
Diffstat (limited to 'lang/qt/src/job.cpp')
-rw-r--r-- | lang/qt/src/job.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/lang/qt/src/job.cpp b/lang/qt/src/job.cpp index 8ed0b576..c346a355 100644 --- a/lang/qt/src/job.cpp +++ b/lang/qt/src/job.cpp @@ -5,6 +5,8 @@ Copyright (c) 2004,2005 Klarälvdalens Datakonsult AB Copyright (c) 2016 by Bundesamt für Sicherheit in der Informationstechnik Software engineering by Intevation GmbH + Copyright (c) 2021 g10 Code GmbH + Software engineering by Ingo Klöcker <[email protected]> QGpgME is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -37,6 +39,7 @@ #endif #include "job.h" +#include "job_p.h" #include "keylistjob.h" #include "listallkeysjob.h" @@ -72,6 +75,25 @@ #include <gpg-error.h> +#include <unordered_map> + +namespace +{ +typedef std::unordered_map<const QGpgME::Job*, std::unique_ptr<QGpgME::JobPrivate>> JobPrivateHash; +Q_GLOBAL_STATIC(JobPrivateHash, d_func) +} + +void QGpgME::setJobPrivate(const Job *job, std::unique_ptr<JobPrivate> d) +{ + auto &ref = d_func()->operator[](job); + ref = std::move(d); +} + +QGpgME::JobPrivate *QGpgME::getJobPrivate(const Job *job) +{ + return d_func()->operator[](job).get(); +} + QGpgME::Job::Job(QObject *parent) : QObject(parent) { |