On Tuesday 19 March 2013 15:11:03 André Somers wrote:
> Op 19-3-2013 14:57, K. Frank schreef:
> > Hello Tony!
> > 
> > I have something of a side question, below.
> > 
> > On Tue, Mar 19, 2013 at 2:09 AM, Tony Rietwyk <t...@rightsoft.com.au> 
wrote:
> >> Hi Ken,
> >> ...
> >> // Hack to get around Qt strictness...
> >> 
> >> class TSleepThread: public QThread
> >> {
> >> 
> >> public:
> >>        static void sleep(unsigned long secs) { QThread::sleep(secs); };
> >>        static void msleep(unsigned long msecs) { QThread::msleep(msecs);
> >>        };
> >>        static void usleep(unsigned long usecs) { QThread::usleep(usecs);
> >>        };
> >> 
> >> };
> >> ...
> > 
> > I've done this "hack" before to unprotect QThread::sleep.  But for the
> > life of me I cannot figure out why QThread:: sleep is protected (or, at
> > least, why there isn't some other unprotected static sleep somewhere).
> > 
> > A cross-platform sleep (in a cross-platform framework, at that).  What's
> > not to like?
> > 
> > But seriously, does anyone know what the motivation for making sleep
> > protected might have been?
> 
> I'm not sure, probably to discourage its usage. Anyway, in Qt 5, there
> now are static public member functions sleep and usleep in QThread.

Sleep being public tends to make users think it could be called from anywhere 
(not only from within the thread) which might have sideeffects. Thus, 
overwriting QThread implies you're doing sth. non standard and you know what 
you are doing.

Frank
_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to