passing const ref when copy not needed

This commit is contained in:
Gaelle Braud 2026-01-26 12:30:40 +01:00
parent 7aad75075e
commit 4c9d6b4d7c
5 changed files with 5 additions and 5 deletions

View file

@ -121,7 +121,7 @@ ChatCore::~ChatCore() {
emit mChatModel->removeListener();
}
void ChatCore::setSelf(QSharedPointer<ChatCore> me) {
void ChatCore::setSelf(const QSharedPointer<ChatCore> &me) {
mChatModelConnection = SafeConnection<ChatCore, ChatModel>::create(me, mChatModel);
mChatModelConnection->makeConnectToCore(&ChatCore::lDeleteHistory, [this]() {
mChatModelConnection->invokeToModel([this]() { mChatModel->deleteHistory(); });

View file

@ -74,7 +74,7 @@ public:
static QSharedPointer<ChatCore> create(const std::shared_ptr<linphone::ChatRoom> &chatRoom);
ChatCore(const std::shared_ptr<linphone::ChatRoom> &chatRoom);
~ChatCore();
void setSelf(QSharedPointer<ChatCore> me);
void setSelf(const QSharedPointer<ChatCore> &me);
QDateTime getLastUpdatedTime() const;
void setLastUpdatedTime(QDateTime time);

View file

@ -157,7 +157,7 @@ ChatMessageCore::ChatMessageCore(const std::shared_ptr<linphone::ChatMessage> &c
mTotalReactionsLabel = tr("all_reactions_label");
auto reac = chatmessage->getOwnReaction();
mOwnReaction = reac ? Utils::coreStringToAppString(reac->getBody()) : QString();
for (auto &reaction : chatmessage->getReactions()) {
for (const auto &reaction : chatmessage->getReactions()) {
if (reaction) {
auto fromAddr = reaction->getFromAddress()->clone();
fromAddr->clean();

View file

@ -91,7 +91,7 @@ void EventLogList::setChatCore(QSharedPointer<ChatCore> core) {
connect(mChatCore.get(), &ChatCore::eventListCleared, this, [this] { resetData(); });
connect(mChatCore.get(), &ChatCore::eventsInserted, this, [this](QList<QSharedPointer<EventLogCore>> list) {
auto eventsList = getSharedList<EventLogCore>();
for (auto &event : list) {
for (const auto &event : list) {
auto it = std::find_if(eventsList.begin(), eventsList.end(),
[event](const QSharedPointer<EventLogCore> item) { return item == event; });
if (it == eventsList.end()) {

View file

@ -66,7 +66,7 @@ template <class A, class B>
class SafeConnection : public QObject {
// Use create functions.
protected:
SafeConnection(QSharedPointer<A> a, std::shared_ptr<B> b)
SafeConnection(const QSharedPointer<A> &a, std::shared_ptr<B> b)
: mCore(a), mModel(b), mCoreObject(a.get()), mModelObject(b.get()) {
}
SafeConnection(QSharedPointer<A> a, QSharedPointer<B> b)