[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: Re: extragear/multimedia/amarok/src/contextview
From: "Maximilian Kossick" <maximilian.kossick () googlemail ! com>
Date: 2007-07-13 10:17:46
Message-ID: c3d78d90707130317w78cd7f83h8f9923c73462221 () mail ! gmail ! com
[Download RAW message or body]
Are you sure it's safe to update a GUI component from another thread? And it
might be useful to stop the thread if Amarok is minimised to prevent the
thread from waking up the CPU 50 times a second.
On 7/13/07, Mark Kretschmann <kretschmann@kde.org> wrote:
>
> SVN commit 687330 by markey:
>
> Use a separate QThread with its own event loop to update the view. My hope
> was that this would allow to keep a constant frame rate even when Amarok is
> busy.
>
> Seems to improve things somewhat, but I'm not 100% happy with the result
> yet. Animation still hickups when you e.g. open the settings dialog.
>
>
> M +30 -3 CoverBling.cpp
> M +13 -0 CoverBling.h
>
>
> --- trunk/extragear/multimedia/amarok/src/contextview/CoverBling.cpp
> #687329:687330
> @@ -17,6 +17,8 @@
> * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
> USA. *
>
> ***************************************************************************/
>
> +#define DEBUG_PREFIX "CoverBling"
> +
> #include "debug.h"
> #include "CoverBling.h"
>
> @@ -35,9 +37,8 @@
>
> setFixedHeight( 200 );
>
> - QTimer* timer = new QTimer( this );
> - connect( timer, SIGNAL( timeout() ), this, SLOT( updateGL() ) );
> - timer->start( 20 ); //50fps
> + UpdateThread* thread = new UpdateThread( this );
> + thread->start( QThread::TimeCriticalPriority );
> }
>
> void
> @@ -174,5 +175,31 @@
> }
>
>
> +UpdateThread::UpdateThread( QObject* parent )
> + : QThread( parent )
> +{
> + DEBUG_BLOCK
> +}
> +
> +void
> +UpdateThread::run()
> +{
> + DEBUG_BLOCK
> +
> + CoverBling* cb = static_cast<CoverBling*>( parent() );
> +
> +// while( true ) {
> +// cb->updateGL();
> +// msleep( 20 );
> +// }
> +
> + QTimer* timer = new QTimer( this );
> + connect( timer, SIGNAL( timeout() ), cb, SLOT( updateGL() ) );
> + timer->start( 20 ); //50fps
> +
> + exec();
> +}
> +
> +
> #include "CoverBling.moc"
>
> --- trunk/extragear/multimedia/amarok/src/contextview/CoverBling.h
> #687329:687330
> @@ -21,6 +21,7 @@
> #define AMAROK_COVERBLING_H
>
> #include <QGLWidget>
> +#include <QThread>
>
>
> class CoverBling : public QGLWidget
> @@ -48,6 +49,18 @@
> };
>
>
> +class UpdateThread : public QThread
> +{
> + Q_OBJECT
> +
> + public:
> + UpdateThread( QObject* parent );
> +
> + protected:
> + void run();
> +};
> +
> +
> #endif /* AMAROK_COVERBLING_H */
>
>
>
[Attachment #3 (text/html)]
Are you sure it's safe to update a GUI component from another thread? And it \
might be useful to stop the thread if Amarok is minimised to prevent the thread from \
waking up the CPU 50 times a second.<br><br><div><span class="gmail_quote"> On \
7/13/07, <b class="gmail_sendername">Mark Kretschmann</b> <<a \
href="mailto:kretschmann@kde.org">kretschmann@kde.org</a>> \
wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, \
204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"> SVN commit 687330 by \
markey:<br><br>Use a separate QThread with its own event loop to update the view. My \
hope was that this would allow to keep a constant frame rate even when Amarok is \
busy.<br><br>Seems to improve things somewhat, but I'm not 100% happy with the \
result yet. Animation still hickups when you e.g. open the settings \
dialog.<br><br><br> M +30 -3 CoverBling.cpp<br> \
M +13 -0 CoverBling.h<br><br><br>--- \
trunk/extragear/multimedia/amarok/src/contextview/CoverBling.cpp #687329:687330<br>@@ \
-17,6 +17,8 @@<br> * 51 Franklin Street, Fifth Floor, Boston, \
MA 02110-1301, \
USA. *<br> ***** \
**********************************************************************/<br><br>+#define \
DEBUG_PREFIX "CoverBling"<br>+<br> #include "debug.h"<br> \
#include "CoverBling.h"<br><br>@@ -35,9 +37,8 \
@@<br><br> setFixedHeight( 200 \
);<br><br>- QTimer* timer = new QTimer( this \
);<br>- connect( timer, SIGNAL( timeout() ), this, SLOT( \
updateGL() ) ); <br>- timer->start( 20 ); \
//50fps<br>+ UpdateThread* thread = new UpdateThread( this \
);<br>+ thread->start( QThread::TimeCriticalPriority );<br> \
}<br><br> void<br>@@ -174,5 +175,31 @@<br> }<br><br><br>+UpdateThread::UpdateThread( \
QObject* parent ) <br>+ : QThread( \
parent )<br>+{<br>+ DEBUG_BLOCK<br>+}<br>+<br>+void<br>+UpdateT \
hread::run()<br>+{<br>+ DEBUG_BLOCK<br>+<br>+ CoverBling* \
cb = static_cast<CoverBling*>( parent() \
);<br>+<br>+// while( true ) { \
<br>+// cb->updateGL();<br>+// msleep( \
20 );<br>+// }<br>+<br>+ QTimer* timer \
= new QTimer( this );<br>+ connect( timer, SIGNAL( timeout() \
), cb, SLOT( updateGL() ) );<br>+ timer->start( 20 ); \
//50fps <br>+<br>+ exec();<br>+}<br>+<br>+<br> #include \
"CoverBling.moc"<br><br>--- \
trunk/extragear/multimedia/amarok/src/contextview/CoverBling.h #687329:687330<br>@@ \
-21,6 +21,7 @@<br> #define AMAROK_COVERBLING_H<br> <br> #include \
<QGLWidget><br>+#include <QThread><br><br><br> class CoverBling : public \
QGLWidget<br>@@ -48,6 +49,18 @@<br> };<br><br><br>+class UpdateThread : public \
QThread<br>+{<br>+ Q_OBJECT<br>+<br>+ public:
<br>+ UpdateThread( QObject* parent \
);<br>+<br>+ protected:<br>+ void \
run();<br>+};<br>+<br>+<br> #endif /* AMAROK_COVERBLING_H \
*/<br><br><br></blockquote></div><br>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic