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
cc40bead
Commit
cc40bead
authored
Mar 23, 2017
by
Ronan Abhamon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(app): avoid double free on shared singleton (qml/c++)
parent
9e8b6b59
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
53 additions
and
92 deletions
+53
-92
CMakeLists.txt
linphone-desktop/CMakeLists.txt
+1
-1
App.cpp
linphone-desktop/src/app/App.cpp
+43
-82
App.hpp
linphone-desktop/src/app/App.hpp
+4
-4
main.cpp
linphone-desktop/src/main.cpp
+5
-5
No files found.
linphone-desktop/CMakeLists.txt
View file @
cc40bead
...
...
@@ -56,7 +56,7 @@ if(NOT WIN32)
endif
()
endif
()
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
${
CUSTOM_FLAGS
}
"
)
set
(
CMAKE_CXX_FLAGS_DEBUG
"
${
CMAKE_CXX_FLAGS_DEBUG
}
"
)
set
(
CMAKE_CXX_FLAGS_DEBUG
"
${
CMAKE_CXX_FLAGS_DEBUG
}
-DQT_QML_DEBUG -DQT_DECLARATIVE_DEBUG
"
)
# ------------------------------------------------------------------------------
# Define packages, libs, sources, headers, resources and languages.
...
...
linphone-desktop/src/app/App.cpp
View file @
cc40bead
...
...
@@ -99,9 +99,6 @@ void App::initContentApp () {
CoreManager
::
init
(
this
,
m_parser
.
value
(
"config"
));
qInfo
()
<<
"Activated selectors:"
<<
QQmlFileSelector
::
get
(
&
m_engine
)
->
selector
()
->
allSelectors
();
// Avoid double free.
m_engine
.
setObjectOwnership
(
this
,
QQmlEngine
::
CppOwnership
);
// Provide `+custom` folders for custom components.
{
QQmlFileSelector
*
file_selector
=
new
QQmlFileSelector
(
&
m_engine
);
...
...
@@ -243,8 +240,9 @@ QQuickWindow *App::getCallsWindow () {
}
QQuickWindow
*
App
::
getMainWindow
()
const
{
QQmlApplicationEngine
&
engine
=
const_cast
<
QQmlApplicationEngine
&>
(
m_engine
);
return
qobject_cast
<
QQuickWindow
*>
(
engine
.
rootObjects
().
at
(
0
));
return
qobject_cast
<
QQuickWindow
*>
(
const_cast
<
QQmlApplicationEngine
*>
(
&
m_engine
)
->
rootObjects
().
at
(
0
)
);
}
QQuickWindow
*
App
::
getSettingsWindow
()
{
...
...
@@ -273,9 +271,36 @@ bool App::hasFocus () const {
// -----------------------------------------------------------------------------
#define REGISTER_EXISTING_SINGLETON(TYPE, NAME, METHOD) qmlRegisterSingletonType<TYPE>( \
"Linphone", 1, 0, NAME, \
[](QQmlEngine *, QJSEngine *) -> QObject *{ \
QObject *object = METHOD(); \
QQmlEngine::setObjectOwnership(object, QQmlEngine::CppOwnership); \
return object; \
} \
)
template
<
class
T
>
void
registerSingletonType
(
const
char
*
name
)
{
qmlRegisterSingletonType
<
T
>
(
"Linphone"
,
1
,
0
,
name
,
[](
QQmlEngine
*
,
QJSEngine
*
)
->
QObject
*
{
return
new
T
();
}
);
}
void
App
::
registerTypes
()
{
qInfo
()
<<
"Registering types..."
;
qmlRegisterType
<
Camera
>
(
"Linphone"
,
1
,
0
,
"Camera"
);
qmlRegisterType
<
ContactsListProxyModel
>
(
"Linphone"
,
1
,
0
,
"ContactsListProxyModel"
);
qmlRegisterType
<
ChatModel
>
(
"Linphone"
,
1
,
0
,
"ChatModel"
);
qmlRegisterType
<
ChatProxyModel
>
(
"Linphone"
,
1
,
0
,
"ChatProxyModel"
);
qmlRegisterType
<
SmartSearchBarModel
>
(
"Linphone"
,
1
,
0
,
"SmartSearchBarModel"
);
qRegisterMetaType
<
ChatModel
::
EntryType
>
(
"ChatModel::EntryType"
);
qmlRegisterUncreatableType
<
CallModel
>
(
"Linphone"
,
1
,
0
,
"CallModel"
,
"CallModel is uncreatable."
);
...
...
@@ -289,85 +314,21 @@ void App::registerTypes () {
"Linphone"
,
1
,
0
,
"VcardModel"
,
"VcardModel is uncreatable."
);
qmlRegisterSingletonType
<
App
>
(
"Linphone"
,
1
,
0
,
"App"
,
[](
QQmlEngine
*
,
QJSEngine
*
)
->
QObject
*
{
return
App
::
getInstance
();
}
);
qmlRegisterSingletonType
<
CoreManager
>
(
"Linphone"
,
1
,
0
,
"CoreManager"
,
[](
QQmlEngine
*
,
QJSEngine
*
)
->
QObject
*
{
return
CoreManager
::
getInstance
();
}
);
qmlRegisterSingletonType
<
AccountSettingsModel
>
(
"Linphone"
,
1
,
0
,
"AccountSettingsModel"
,
[](
QQmlEngine
*
,
QJSEngine
*
)
->
QObject
*
{
return
new
AccountSettingsModel
();
}
);
qmlRegisterSingletonType
<
CallsListModel
>
(
"Linphone"
,
1
,
0
,
"CallsListModel"
,
[](
QQmlEngine
*
,
QJSEngine
*
)
->
QObject
*
{
return
CoreManager
::
getInstance
()
->
getCallsListModel
();
}
);
qmlRegisterSingletonType
<
ContactsListModel
>
(
"Linphone"
,
1
,
0
,
"ContactsListModel"
,
[](
QQmlEngine
*
,
QJSEngine
*
)
->
QObject
*
{
return
CoreManager
::
getInstance
()
->
getContactsListModel
();
}
);
qmlRegisterSingletonType
<
Presence
>
(
"Linphone"
,
1
,
0
,
"Presence"
,
[](
QQmlEngine
*
,
QJSEngine
*
)
->
QObject
*
{
return
new
Presence
();
}
);
qmlRegisterSingletonType
<
PresenceStatusModel
>
(
"Linphone"
,
1
,
0
,
"PresenceStatusModel"
,
[](
QQmlEngine
*
,
QJSEngine
*
)
->
QObject
*
{
return
new
PresenceStatusModel
();
}
);
qmlRegisterSingletonType
<
SettingsModel
>
(
"Linphone"
,
1
,
0
,
"SettingsModel"
,
[](
QQmlEngine
*
,
QJSEngine
*
)
->
QObject
*
{
return
CoreManager
::
getInstance
()
->
getSettingsModel
();
}
);
qmlRegisterSingletonType
<
SipAddressesModel
>
(
"Linphone"
,
1
,
0
,
"SipAddressesModel"
,
[](
QQmlEngine
*
,
QJSEngine
*
)
->
QObject
*
{
return
CoreManager
::
getInstance
()
->
getSipAddressesModel
();
}
);
qmlRegisterSingletonType
<
TimelineModel
>
(
"Linphone"
,
1
,
0
,
"TimelineModel"
,
[](
QQmlEngine
*
,
QJSEngine
*
)
->
QObject
*
{
return
new
TimelineModel
();
}
);
qmlRegisterType
<
Camera
>
(
"Linphone"
,
1
,
0
,
"Camera"
);
qmlRegisterType
<
ContactsListProxyModel
>
(
"Linphone"
,
1
,
0
,
"ContactsListProxyModel"
);
qmlRegisterType
<
ChatModel
>
(
"Linphone"
,
1
,
0
,
"ChatModel"
);
qmlRegisterType
<
ChatProxyModel
>
(
"Linphone"
,
1
,
0
,
"ChatProxyModel"
);
qmlRegisterType
<
SmartSearchBarModel
>
(
"Linphone"
,
1
,
0
,
"SmartSearchBarModel"
);
qRegisterMetaType
<
ChatModel
::
EntryType
>
(
"ChatModel::EntryType"
);
registerSingletonType
<
AccountSettingsModel
>
(
"AccountSettingsModel"
);
registerSingletonType
<
Presence
>
(
"Presence"
);
registerSingletonType
<
PresenceStatusModel
>
(
"PresenceStatusModel"
);
registerSingletonType
<
TimelineModel
>
(
"TimelineModel"
);
REGISTER_EXISTING_SINGLETON
(
App
,
"App"
,
App
::
getInstance
);
REGISTER_EXISTING_SINGLETON
(
CoreManager
,
"CoreManager"
,
CoreManager
::
getInstance
);
REGISTER_EXISTING_SINGLETON
(
SettingsModel
,
"SettingsModel"
,
CoreManager
::
getInstance
()
->
getSettingsModel
);
REGISTER_EXISTING_SINGLETON
(
SipAddressesModel
,
"SipAddressesModel"
,
CoreManager
::
getInstance
()
->
getSipAddressesModel
);
REGISTER_EXISTING_SINGLETON
(
CallsListModel
,
"CallsListModel"
,
CoreManager
::
getInstance
()
->
getCallsListModel
);
REGISTER_EXISTING_SINGLETON
(
ContactsListModel
,
"ContactsListModel"
,
CoreManager
::
getInstance
()
->
getContactsListModel
);
}
#undef REGISTER_EXISTING_SINGLETON
// -----------------------------------------------------------------------------
void
App
::
setTrayIcon
()
{
...
...
linphone-desktop/src/app/App.hpp
View file @
cc40bead
...
...
@@ -89,15 +89,15 @@ private:
}
QCommandLineParser
m_parser
;
QVariantList
m_available_locales
;
QString
m_locale
;
QQmlApplicationEngine
m_engine
;
DefaultTranslator
*
m_translator
=
nullptr
;
Notifier
*
m_notifier
=
nullptr
;
QVariantList
m_available_locales
;
QString
m_locale
;
QQuickWindow
*
m_calls_window
=
nullptr
;
QQuickWindow
*
m_settings_window
=
nullptr
;
};
...
...
linphone-desktop/src/main.cpp
View file @
cc40bead
...
...
@@ -35,11 +35,11 @@ int main (int argc, char *argv[]) {
// ---------------------------------------------------------------------------
// Options to get a nice video render.
#ifdef _WIN32
#ifdef _WIN32
QCoreApplication
::
setAttribute
(
Qt
::
AA_UseOpenGLES
,
true
);
#else
#else
QCoreApplication
::
setAttribute
(
Qt
::
AA_UseDesktopOpenGL
,
true
);
#endif
#endif // ifdef _WIN32
QCoreApplication
::
setAttribute
(
Qt
::
AA_ShareOpenGLContexts
,
true
);
{
...
...
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