Merge lp:~renatofilho/mediaplayer-app/fix-app-crash into lp:mediaplayer-app

Proposed by Renato Araujo Oliveira Filho
Status: Merged
Approved by: Tiago Salem Herrmann
Approved revision: 85
Merged at revision: 79
Proposed branch: lp:~renatofilho/mediaplayer-app/fix-app-crash
Merge into: lp:mediaplayer-app
Diff against target: 116 lines (+25/-6)
3 files modified
src/qml/player/TimeLine.qml (+2/-4)
src/thumbnail-provider.cpp (+21/-2)
src/thumbnail-provider.h (+2/-0)
To merge this branch: bzr merge lp:~renatofilho/mediaplayer-app/fix-app-crash
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Tiago Salem Herrmann (community) Approve
Gustavo Pichorim Boiko (community) Needs Information
Review via email: mp+162438@code.launchpad.net

Commit message

Fixed application exit during the thumbnail generation.
Avoid application crashes due a SDK bug.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Florian Boucault (fboucault) wrote :
81. By Renato Araujo Oliveira Filho

Added new package (qt 5.0.2) libqt5multimedia5-plugins as dependency.

82. By Renato Araujo Oliveira Filho

Fixed theme loader with a proper solution.

Revision history for this message
Gustavo Pichorim Boiko (boiko) wrote :

56 delete m_player;
57 + m_player = 0;

As you have used a mutex in the other played destruction code, shouldn't you add the mutex here too?

review: Needs Information
Revision history for this message
Gustavo Pichorim Boiko (boiko) wrote :

76 + // check if the player exists ( the application still running )
77 + if (!m_player) {
78 + return QImage();
79 + }
80 +
81 + m_mutex.lock();

Why there is the need to check for m_player before and after locking the mutex? Wouldn't it be enough to check for the player just after the mutex acquires the lock?

review: Needs Information
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
83. By Renato Araujo Oliveira Filho

Used QMutexLocker to make the code cleaner.

84. By Renato Araujo Oliveira Filho

Added more comments.

85. By Renato Araujo Oliveira Filho

Reverted qt 5.0.2 related changes.

Revision history for this message
Tiago Salem Herrmann (tiagosh) wrote :

looks good to me.
+1.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/qml/player/TimeLine.qml'
2--- src/qml/player/TimeLine.qml 2013-04-15 12:58:52 +0000
3+++ src/qml/player/TimeLine.qml 2013-05-08 21:25:27 +0000
4@@ -20,6 +20,7 @@
5 import QtQuick 2.0
6 import Ubuntu.Components 0.1
7 import "../sdk"
8+import "../theme"
9
10 Item {
11 id: _timeLine
12@@ -40,14 +41,11 @@
13 // "property alias value: _slider.value" does not work
14 Binding { target: _slider; property: "value"; value: _timeLine.value }
15
16- Component.onCompleted: {
17- var result = Theme.loadTheme(Qt.resolvedUrl("../theme/theme.qmltheme"))
18- }
19-
20 Slider {
21 id: _slider
22
23 objectName: "TimeLine.Slider"
24+ ItemStyle.delegate: VideoSlider {property Item item: _slider}
25 anchors {
26 top: parent.top
27 bottom: parent.bottom
28
29=== modified file 'src/thumbnail-provider.cpp'
30--- src/thumbnail-provider.cpp 2013-04-04 18:55:30 +0000
31+++ src/thumbnail-provider.cpp 2013-05-08 21:25:27 +0000
32@@ -20,6 +20,7 @@
33 #include <QtCore/QStringList>
34 #include <QtCore/QTimer>
35 #include <QtCore/QMutex>
36+#include <QtCore/QMutexLocker>
37 #include <QtCore/QCoreApplication>
38 #include <QtMultimedia/QVideoRendererControl>
39 #include <QtMultimedia/QMediaService>
40@@ -30,14 +31,16 @@
41 QQuickImageProvider(QQuickImageProvider::Image),
42 m_player(0)
43 {
44- connect(qApp, SIGNAL(aboutToQuit()), this, SLOT(applicationAboutToQuit()));
45+ connect(qApp, SIGNAL(aboutToQuit()), this, SLOT(applicationAboutToQuit()), Qt::DirectConnection);
46 createPlayer();
47 }
48
49 ThumbnailProvider::~ThumbnailProvider()
50 {
51 if (m_player) {
52+ QMutexLocker locker(&m_mutex);
53 delete m_player;
54+ m_player = 0;
55 }
56 }
57
58@@ -48,6 +51,7 @@
59
60 void ThumbnailProvider::applicationAboutToQuit()
61 {
62+ QMutexLocker locker(&m_mutex);
63 delete m_player;
64 m_player = 0;
65 }
66@@ -79,6 +83,19 @@
67 return QImage();
68 }
69
70+ // check if the player exists ( the application still running )
71+ if (!m_player) {
72+ return QImage();
73+ }
74+
75+ QMutexLocker locker(&m_mutex);
76+
77+ // again check if the player exits after lock the mutex, since this function will run in a separed thread,
78+ // the application could be destroyed at this point and the function applicationAboutToQuit was called
79+ if (!m_player) {
80+ return QImage();
81+ }
82+
83 if (uri != m_player->uri()) {
84 m_player->setUri(uri);
85 m_cache.clear();
86@@ -89,7 +106,9 @@
87 img = m_cache[time];
88 } else {
89 img = m_player->request(time, requestedSize).copy();
90- m_cache.insert(time, img);
91+ if (!img.isNull()) {
92+ m_cache.insert(time, img);
93+ }
94 }
95
96 *size = img.size();
97
98=== modified file 'src/thumbnail-provider.h'
99--- src/thumbnail-provider.h 2013-02-12 14:30:57 +0000
100+++ src/thumbnail-provider.h 2013-05-08 21:25:27 +0000
101@@ -23,6 +23,7 @@
102 #include <QtGui/QImage>
103 #include <QtCore/QMap>
104 #include <QtCore/QQueue>
105+#include <QtCore/QMutex>
106
107 class ThumbnailPipeline;
108
109@@ -42,6 +43,7 @@
110 private:
111 ThumbnailPipeline *m_player;
112 QMap<qint64, QImage> m_cache;
113+ QMutex m_mutex;
114
115 void createPlayer();
116 QString parseThumbnailName(const QString &id, qint64 *time) const;

Subscribers

People subscribed via source and target branches