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
=== modified file 'src/qml/player/TimeLine.qml'
--- src/qml/player/TimeLine.qml 2013-04-15 12:58:52 +0000
+++ src/qml/player/TimeLine.qml 2013-05-08 21:25:27 +0000
@@ -20,6 +20,7 @@
20import QtQuick 2.020import QtQuick 2.0
21import Ubuntu.Components 0.121import Ubuntu.Components 0.1
22import "../sdk"22import "../sdk"
23import "../theme"
2324
24Item {25Item {
25 id: _timeLine26 id: _timeLine
@@ -40,14 +41,11 @@
40 // "property alias value: _slider.value" does not work41 // "property alias value: _slider.value" does not work
41 Binding { target: _slider; property: "value"; value: _timeLine.value }42 Binding { target: _slider; property: "value"; value: _timeLine.value }
4243
43 Component.onCompleted: {
44 var result = Theme.loadTheme(Qt.resolvedUrl("../theme/theme.qmltheme"))
45 }
46
47 Slider {44 Slider {
48 id: _slider45 id: _slider
4946
50 objectName: "TimeLine.Slider"47 objectName: "TimeLine.Slider"
48 ItemStyle.delegate: VideoSlider {property Item item: _slider}
51 anchors {49 anchors {
52 top: parent.top50 top: parent.top
53 bottom: parent.bottom51 bottom: parent.bottom
5452
=== modified file 'src/thumbnail-provider.cpp'
--- src/thumbnail-provider.cpp 2013-04-04 18:55:30 +0000
+++ src/thumbnail-provider.cpp 2013-05-08 21:25:27 +0000
@@ -20,6 +20,7 @@
20#include <QtCore/QStringList>20#include <QtCore/QStringList>
21#include <QtCore/QTimer>21#include <QtCore/QTimer>
22#include <QtCore/QMutex>22#include <QtCore/QMutex>
23#include <QtCore/QMutexLocker>
23#include <QtCore/QCoreApplication>24#include <QtCore/QCoreApplication>
24#include <QtMultimedia/QVideoRendererControl>25#include <QtMultimedia/QVideoRendererControl>
25#include <QtMultimedia/QMediaService>26#include <QtMultimedia/QMediaService>
@@ -30,14 +31,16 @@
30 QQuickImageProvider(QQuickImageProvider::Image),31 QQuickImageProvider(QQuickImageProvider::Image),
31 m_player(0)32 m_player(0)
32{33{
33 connect(qApp, SIGNAL(aboutToQuit()), this, SLOT(applicationAboutToQuit()));34 connect(qApp, SIGNAL(aboutToQuit()), this, SLOT(applicationAboutToQuit()), Qt::DirectConnection);
34 createPlayer();35 createPlayer();
35}36}
3637
37ThumbnailProvider::~ThumbnailProvider()38ThumbnailProvider::~ThumbnailProvider()
38{39{
39 if (m_player) {40 if (m_player) {
41 QMutexLocker locker(&m_mutex);
40 delete m_player;42 delete m_player;
43 m_player = 0;
41 }44 }
42}45}
4346
@@ -48,6 +51,7 @@
4851
49void ThumbnailProvider::applicationAboutToQuit()52void ThumbnailProvider::applicationAboutToQuit()
50{53{
54 QMutexLocker locker(&m_mutex);
51 delete m_player;55 delete m_player;
52 m_player = 0;56 m_player = 0;
53}57}
@@ -79,6 +83,19 @@
79 return QImage(); 83 return QImage();
80 }84 }
8185
86 // check if the player exists ( the application still running )
87 if (!m_player) {
88 return QImage();
89 }
90
91 QMutexLocker locker(&m_mutex);
92
93 // again check if the player exits after lock the mutex, since this function will run in a separed thread,
94 // the application could be destroyed at this point and the function applicationAboutToQuit was called
95 if (!m_player) {
96 return QImage();
97 }
98
82 if (uri != m_player->uri()) {99 if (uri != m_player->uri()) {
83 m_player->setUri(uri);100 m_player->setUri(uri);
84 m_cache.clear();101 m_cache.clear();
@@ -89,7 +106,9 @@
89 img = m_cache[time];106 img = m_cache[time];
90 } else {107 } else {
91 img = m_player->request(time, requestedSize).copy();108 img = m_player->request(time, requestedSize).copy();
92 m_cache.insert(time, img);109 if (!img.isNull()) {
110 m_cache.insert(time, img);
111 }
93 }112 }
94113
95 *size = img.size();114 *size = img.size();
96115
=== modified file 'src/thumbnail-provider.h'
--- src/thumbnail-provider.h 2013-02-12 14:30:57 +0000
+++ src/thumbnail-provider.h 2013-05-08 21:25:27 +0000
@@ -23,6 +23,7 @@
23#include <QtGui/QImage>23#include <QtGui/QImage>
24#include <QtCore/QMap>24#include <QtCore/QMap>
25#include <QtCore/QQueue>25#include <QtCore/QQueue>
26#include <QtCore/QMutex>
2627
27class ThumbnailPipeline;28class ThumbnailPipeline;
2829
@@ -42,6 +43,7 @@
42 private:43 private:
43 ThumbnailPipeline *m_player;44 ThumbnailPipeline *m_player;
44 QMap<qint64, QImage> m_cache;45 QMap<qint64, QImage> m_cache;
46 QMutex m_mutex;
4547
46 void createPlayer();48 void createPlayer();
47 QString parseThumbnailName(const QString &id, qint64 *time) const;49 QString parseThumbnailName(const QString &id, qint64 *time) const;

Subscribers

People subscribed via source and target branches