Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
linphone-desktop
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
linphone-desktop
Commits
9a269a14
Commit
9a269a14
authored
Mar 24, 2017
by
Ronan Abhamon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(src/components/contacts/ContactsListModel): set parent of contacts (avoid leaks)
parent
e66f46f3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
9 deletions
+7
-9
ContactModel.cpp
linphone-desktop/src/components/contact/ContactModel.cpp
+2
-2
ContactModel.hpp
linphone-desktop/src/components/contact/ContactModel.hpp
+2
-2
ContactsListModel.cpp
...one-desktop/src/components/contacts/ContactsListModel.cpp
+3
-5
No files found.
linphone-desktop/src/components/contact/ContactModel.cpp
View file @
9a269a14
...
...
@@ -30,7 +30,7 @@ using namespace std;
// =============================================================================
ContactModel
::
ContactModel
(
shared_ptr
<
linphone
::
Friend
>
linphone_friend
)
{
ContactModel
::
ContactModel
(
QObject
*
parent
,
shared_ptr
<
linphone
::
Friend
>
linphone_friend
)
:
QObject
(
parent
)
{
m_linphone_friend
=
linphone_friend
;
m_vcard
=
make_shared
<
VcardModel
>
(
linphone_friend
->
getVcard
());
...
...
@@ -38,7 +38,7 @@ ContactModel::ContactModel (shared_ptr<linphone::Friend> linphone_friend) {
m_linphone_friend
->
setData
(
"contact-model"
,
*
this
);
}
ContactModel
::
ContactModel
(
VcardModel
*
vcard
)
{
ContactModel
::
ContactModel
(
QObject
*
parent
,
VcardModel
*
vcard
)
:
QObject
(
parent
)
{
Q_ASSERT
(
vcard
!=
nullptr
);
QQmlEngine
*
engine
=
App
::
getInstance
()
->
getEngine
();
...
...
linphone-desktop/src/components/contact/ContactModel.hpp
View file @
9a269a14
...
...
@@ -40,8 +40,8 @@ class ContactModel : public QObject {
friend
class
SmartSearchBarModel
;
public:
ContactModel
(
std
::
shared_ptr
<
linphone
::
Friend
>
linphone_friend
);
ContactModel
(
VcardModel
*
vcard
);
ContactModel
(
QObject
*
parent
,
std
::
shared_ptr
<
linphone
::
Friend
>
linphone_friend
);
ContactModel
(
QObject
*
parent
,
VcardModel
*
vcard
);
~
ContactModel
()
=
default
;
std
::
shared_ptr
<
VcardModel
>
getVcardModel
()
const
{
...
...
linphone-desktop/src/components/contacts/ContactsListModel.cpp
View file @
9a269a14
...
...
@@ -37,13 +37,11 @@ ContactsListModel::ContactsListModel (QObject *parent) : QAbstractListModel(pare
// Init contacts with linphone friends list.
for
(
const
auto
&
friend_
:
m_linphone_friends
->
getFriends
())
{
ContactModel
*
contact
=
new
ContactModel
(
friend_
);
ContactModel
*
contact
=
new
ContactModel
(
this
,
friend_
);
// See: http://doc.qt.io/qt-5/qtqml-cppintegration-data.html#data-ownership
// The returned value must have a explicit parent or a QQmlEngine::CppOwnership.
App
::
getInstance
()
->
getEngine
()
->
setObjectOwnership
(
contact
,
QQmlEngine
::
CppOwnership
);
App
::
getInstance
()
->
getEngine
()
->
setObjectOwnership
(
contact
,
QQmlEngine
::
CppOwnership
);
addContact
(
contact
);
}
...
...
@@ -100,7 +98,7 @@ bool ContactsListModel::removeRows (int row, int count, const QModelIndex &paren
// -----------------------------------------------------------------------------
ContactModel
*
ContactsListModel
::
addContact
(
VcardModel
*
vcard
)
{
ContactModel
*
contact
=
new
ContactModel
(
vcard
);
ContactModel
*
contact
=
new
ContactModel
(
this
,
vcard
);
App
::
getInstance
()
->
getEngine
()
->
setObjectOwnership
(
contact
,
QQmlEngine
::
CppOwnership
);
qInfo
()
<<
"Add contact:"
<<
contact
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment