<div class="gmail_quote">On Sun, Nov 8, 2009 at 4:40 PM, Jean-Baptiste Kempf <span dir="ltr"><<a href="mailto:jb@videolan.org">jb@videolan.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

Why so many static_cast? Can't we avoid that?<br></blockquote><div><br>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.<br>
<br>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.<br>
<br>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.<br>
<br>Cheers!<br></div></div>