On 4/12/2012 3:23 PM, Tom Breton (Tehom) wrote:
Clearly something is drastically wrong and varies by setup. I just
can't see how.
Got it...
Looks like the problem is static initialization order:
http://www.parashift.com/c++-faq-lite/ctors.html#faq-10.14
The following lines from ChannelInterval.cpp are part of the problem:
const RealTime ChannelInterval::m_beforeEarliestTime =
RealTime::beforeZeroTime;
const RealTime ChannelInterval::m_earliestTime =
RealTime::zeroTime;
const RealTime ChannelInterval::m_latestTime =
RealTime::beforeMaxTime;
const RealTime ChannelInterval::m_afterLatestTime =
RealTime::maxTime;
Taking ChannelInterval::m_latestTime as an example, it is based on
RealTime::beforeMaxTime. The problem is that both of these are statics.
Since C++ does not guarantee any particular order for the
initialization of statics, it is entirely possible that
ChannelInterval::m_latestTime is initialized before
RealTime::beforeMaxTime. Needless to say, this will have disastrous
consequences as ChannelInterval::m_latestTime will not have the expected
value.
The solution? Well, there are several. Among them:
1. Get rid of the ChannelInterval static constants. Just use the
RealTime ones directly.
2. Use #defines.
3. Initialize the ChannelInterval static constants the same way the
RealTime constants are initialized.
I would be inclined at this point to use #3 and add a comment to
preserve a link to the RealTime constants:
// Same as RealTime::beforeMaxTime
const RealTime
ChannelInterval::m_latestTime(std::numeric_limits<int>::max(),0);
This at least gives you what you want even if there is a bit of a
double-maintenance headache (however unlikely) lurking.
I just tried this out and it fixes the auto channel bug for me.
Ted.
------------------------------------------------------------------------------
For Developers, A Lot Can Happen In A Second.
Boundary is the first to Know...and Tell You.
Monitor Your Applications in Ultra-Fine Resolution. Try it FREE!
http://p.sf.net/sfu/Boundary-d2dvs2
_______________________________________________
Rosegarden-devel mailing list
[email protected] - use the link below to unsubscribe
https://lists.sourceforge.net/lists/listinfo/rosegarden-devel