From: <pst...@us...> - 2011-08-06 22:29:10
|
Revision: 899 http://jazzplusplus.svn.sourceforge.net/jazzplusplus/?rev=899&view=rev Author: pstieber Date: 2011-08-06 22:29:04 +0000 (Sat, 06 Aug 2011) Log Message: ----------- Creation of a timer relies on access to application traits in wx 2.9. Access to application traits requires the setting of the global application instance. The old code had a static instance of a JZListen class that was derived from wxTimer. This object was created before the application and this was causing problems. I changed the JZListen class to be implemented as a singleton. Modified Paths: -------------- trunk/jazz/src/PianoWindow.cpp trunk/jazz/src/PianoWindow.h Modified: trunk/jazz/src/PianoWindow.cpp =================================================================== --- trunk/jazz/src/PianoWindow.cpp 2011-08-06 21:28:14 UTC (rev 898) +++ trunk/jazz/src/PianoWindow.cpp 2011-08-06 22:29:04 UTC (rev 899) @@ -52,8 +52,32 @@ //***************************************************************************** //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- +JZListen* JZListen::mpInstance = 0; + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +JZListen* JZListen::Instance() +{ + if (!mpInstance) + { + mpInstance = new JZListen; + } + return mpInstance; +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void JZListen::Destroy() +{ + delete mpInstance; + mpInstance = 0; +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- JZListen::JZListen() - : mActive(false), + : wxTimer(), + mActive(false), mPitch(-1), mChannel(-1), mpTrack(0) @@ -635,7 +659,7 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -JZListen JZPianoWindow::mListen; +//JZListen JZPianoWindow::mListen; //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- @@ -3042,7 +3066,7 @@ } else { - mListen.KeyOn( + JZListen::Instance()->KeyOn( pTrack, pKeyOn->GetKey(), pKeyOn->GetChannel(), @@ -3137,7 +3161,7 @@ } else { - mListen.KeyOn( + JZListen::Instance()->KeyOn( pTrack, pKeyOn->GetKey(), pKeyOn->GetChannel(), Modified: trunk/jazz/src/PianoWindow.h =================================================================== --- trunk/jazz/src/PianoWindow.h 2011-08-06 21:28:14 UTC (rev 898) +++ trunk/jazz/src/PianoWindow.h 2011-08-06 22:29:04 UTC (rev 899) @@ -43,19 +43,27 @@ { public: - JZListen(); + static JZListen* Instance(); + static void Destroy(); + void KeyOn( - JZTrack *t, + JZTrack* pTrack, int Pitch, int Channel, int Velocity = 64, int MilliSeconds = 100); - void Notify(); + virtual void Notify(); private: + JZListen(); + + private: + + static JZListen* mpInstance; + bool mActive; int mPitch, mChannel; @@ -293,7 +301,7 @@ private: - static JZListen mListen; +// static JZListen mListen; JZTrack* mpTrack; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |