From 3a157ed8eb2191e758abba1a1ada0fc03c81bd06 Mon Sep 17 00:00:00 2001
From: Andreas Traczyk <andreas.traczyk@savoirfairelinux.com>
Date: Wed, 17 Mar 2021 14:27:19 -0400
Subject: [PATCH] avadapter: return call id by value

This function either returns a reference to a local, or a QString
member whose lifetime is unknown to the caller. We should just
return by value.

Change-Id: Ib87288105daa6bf8cb6b803948411275da980c54
---
 src/avadapter.cpp | 14 ++++++++------
 src/avadapter.h   |  2 +-
 2 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/src/avadapter.cpp b/src/avadapter.cpp
index fe0dcea34..e568b087c 100644
--- a/src/avadapter.cpp
+++ b/src/avadapter.cpp
@@ -88,8 +88,12 @@ AvAdapter::shareEntireScreen(int screenNumber)
         return;
     QRect rect = screen->geometry();
 
-    LRCInstance::avModel()
-        .setDisplay(getScreenNumber(), rect.x(), rect.y(), rect.width(), rect.height(), getCurrentCallId());
+    LRCInstance::avModel().setDisplay(getScreenNumber(),
+                                      rect.x(),
+                                      rect.y(),
+                                      rect.width(),
+                                      rect.height(),
+                                      getCurrentCallId());
 }
 
 void
@@ -206,14 +210,12 @@ AvAdapter::stopAudioMeter(bool async)
     LRCInstance::stopAudioMeter(async);
 }
 
-const QString&
+QString
 AvAdapter::getCurrentCallId()
 {
     const auto& convInfo = LRCInstance::getConversationFromConvUid(LRCInstance::getCurrentConvUid());
     auto call = LRCInstance::getCallInfoForConversation(convInfo);
-    if (!call)
-        return QString();
-    return call->id;
+    return call ? call->id : QString();
 }
 
 void
diff --git a/src/avadapter.h b/src/avadapter.h
index 45bde4577..0e33c5ae6 100644
--- a/src/avadapter.h
+++ b/src/avadapter.h
@@ -91,7 +91,7 @@ private:
     /*
      * Get current callId from current selected conv id.
      */
-    const QString& getCurrentCallId();
+    QString getCurrentCallId();
 
     /*
      * Used to classify capture device events.
-- 
GitLab