mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-05 01:05:34 +08:00
refs #794 Utility function to establish a signal/slot connection that auto-disconnects upon the first delivery.
This commit is contained in:
committed by
Klaus Basan
parent
ab8dcbad97
commit
4ed72706fc
@@ -20,6 +20,7 @@
|
||||
#include "blackmisc/metaclass.h"
|
||||
#include "blackmisc/propertyindex.h"
|
||||
#include "blackmisc/range.h"
|
||||
#include "blackmisc/slot.h"
|
||||
#include "blackmisc/statusmessage.h"
|
||||
#include "blackmisc/valuecacheprivate.h"
|
||||
#include "blackmisc/variant.h"
|
||||
@@ -441,12 +442,7 @@ namespace BlackMisc
|
||||
//! \private Connect a function to be called (only once) when the owner's objectName changes.
|
||||
void onOwnerNameChanged(std::function<void()> function)
|
||||
{
|
||||
auto connection = std::make_shared<QMetaObject::Connection>();
|
||||
*connection = QObject::connect(m_page->parent(), &QObject::objectNameChanged, [connection, function](const QString &)
|
||||
{
|
||||
QObject::disconnect(*connection);
|
||||
function();
|
||||
});
|
||||
connectOnce(m_page->parent(), &QObject::objectNameChanged, [function](const QString &) { function(); });
|
||||
}
|
||||
|
||||
Private::CValuePage *m_page = (qFatal("Must be initialized"), nullptr); //!< \private
|
||||
|
||||
Reference in New Issue
Block a user