[vlc-devel] commit: Qt4: implement PlaylistEventManager functionality in MainInputManager ( Jakob Leben )

Jakob Leben jakob.leben at gmail.com
Mon Nov 9 03:51:31 CET 2009


On Sun, Nov 8, 2009 at 4:40 PM, Jean-Baptiste Kempf <jb at videolan.org> wrote:

> Why so many static_cast? Can't we avoid that?
>

No, we can not avoid casting if we use custom QEvent(s), and in the case of
these callbacks we have to use them. This is so, because it happens that
within the same thread you call a function which changes the playlist and
you had to make that call with playlist locked, but this produces a callback
from the playlist in which you have to lock the playlist again. Using QEvent
postpones the processing of the callback until Qt reaches main event loop
again.

Otherwise, C++ static_cast is completely equivalent to old-school (or
C-style) casting [(Type) variable], it's just a recommended notation,
because it is more obvious. And yes, generally I don't like casting either,
but sometimes you just have to cast. And static_cast is just a better form
of doing the inevitable.

BTW, these callbacks where implemented in PLModel exactly the same way, only
the text had C-style casts instead of static_cast. I saw elsewhere in Remi's
code that he used static_cast notation and I decided I'd use that notation
too.

Cheers!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20091109/63c4fc6f/attachment.html>


More information about the vlc-devel mailing list