Update of /cvsroot/audacity/audacity-src/src/effects In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv12752/src/effects
Modified Files: Equalization.cpp Equalization.h Log Message: Tweaks to fix the remaining EQ batch chain problems. Fixed possible crash when opening dialog, added a 'custom backup' curve so that editing the custom curve for a batch chain doesn't affect the custom curve used when the dialog is opened from the menu. Moved the 'disallow custom' checking into the Validate method, since that's pretty much what it's for. Made pressing 'cancel' on the save dialog work properly when user has pressed OK after editing a batch chain. Moved some repeated tidying-up code into a separate Finish method. Index: Equalization.cpp =================================================================== RCS file: /cvsroot/audacity/audacity-src/src/effects/Equalization.cpp,v retrieving revision 1.101 retrieving revision 1.102 diff -u -d -r1.101 -r1.102 --- Equalization.cpp 7 Aug 2009 15:32:57 -0000 1.101 +++ Equalization.cpp 17 Aug 2009 10:45:55 -0000 1.102 @@ -105,6 +105,7 @@ #include <math.h> #include <wx/arrimpl.cpp> + WX_DEFINE_OBJARRAY( EQPointArray ); WX_DEFINE_OBJARRAY( EQCurveArray ); @@ -441,7 +442,7 @@ hiFreq = ((float)(GetActiveProject()->GetRate())/2.); EqualizationDialog dlog(this, ((double)loFreqI), hiFreq, mFilterFuncR, mFilterFuncI, - windowSize, mCurveName, false, mParent, -1, _("Equalization")); + windowSize, mCurveName, false, NULL, -1, _("Equalization")); dlog.M = mM; dlog.curveName = mCurveName; @@ -952,7 +953,8 @@ const wxSize& size, long style): wxDialog( parent, id, title, position, size, style | wxRESIZE_BORDER | wxMAXIMIZE_BOX ), - mDisallowCustom(disallowCustom) + mDisallowCustom(disallowCustom), + mCustomBackup(wxT("custom")) { m_pEffect = effect; @@ -985,6 +987,13 @@ // Load the EQ curves LoadCurves(); + if (mDisallowCustom) + { + mCustomBackup.Name = wxT("custom"); + EQCurve &realCustom = mCurves[mCurves.GetCount()-1]; + wxASSERT(realCustom.Name.IsSameAs(wxT("custom"))); + mCustomBackup.points = realCustom.points; + } // Create the dialog MakeEqualizationDialog(); @@ -1088,6 +1097,9 @@ // void EqualizationDialog::SaveCurves() { + if (mDisallowCustom) + RevertCustom(); + // Construct default curve filename // // LLL: Wouldn't you know that as of WX 2.6.2, there is a conflict @@ -1400,11 +1412,23 @@ } // -// Validate data (A do nothing routine) +// Validate data // bool EqualizationDialog::Validate() { - return TRUE; + // If editing a batch chain, we don't want to be using the custom curve so + // we offer to save it. + while (mDisallowCustom && curveName.IsSameAs(wxT("custom"))) + { + wxMessageBox(_("To use this EQ curve in a batch chain, please choose a new name for it."), + _("EQ Curve needs a different name"), + wxOK | wxCENTRE, + this); + + if (!SaveAs()) + return false; + } + return true; } // @@ -2576,6 +2600,11 @@ // void EqualizationDialog::OnSaveAs(wxCommandEvent &event) { + SaveAs(); +} + +bool EqualizationDialog::SaveAs() +{ wxString name; int numCurves = mCurves.GetCount(); int curve; @@ -2603,7 +2632,7 @@ { // Show the dialog and bail if the user cancels if( dlg.ShowModal() == wxID_CANCEL ) { - return; + return false; } // Extract the name from the dialog @@ -2640,7 +2669,8 @@ } if( overWrite == false) - { // Create a new entry + { + // Create a new entry mCurves.Add( EQCurve( wxT("custom") ) ); // Copy over the points @@ -2667,6 +2697,7 @@ // Save the curves to file - enables the user to set up curves without applying them SaveCurves(); + return true; } // @@ -2774,7 +2805,14 @@ mPanel->Refresh(false); } -void EqualizationDialog::OnCancel(wxCommandEvent &event) +void EqualizationDialog::RevertCustom() +{ + EQCurve &realCustom = mCurves[mCurves.GetCount()-1]; + wxASSERT(realCustom.Name.IsSameAs(wxT("custom"))); + realCustom.points = mCustomBackup.points; +} + +void EqualizationDialog::Finish(bool ok) { if(mLogEnvelope) delete mLogEnvelope; @@ -2784,7 +2822,15 @@ mLinEnvelope = NULL; mPanel = NULL; - EndModal(false); + EndModal(ok); +} + +void EqualizationDialog::OnCancel(wxCommandEvent &event) +{ + if (mDisallowCustom) + RevertCustom(); + + Finish(false); } void EqualizationDialog::OnOk(wxCommandEvent &event) @@ -2793,22 +2839,11 @@ if( Validate() ) { - if (mDisallowCustom) - { - while (curveName == wxT("custom")) - { - wxMessageBox(_("To use this EQ curve in a batch chain, please choose a new name for it."), - _("EQ Curve needs a different name"), - wxOK | wxCENTRE, - this); - OnSaveAs(event); - } - } - else + // Update custom curve (so it's there for next time) + //(done in a hurry, may not be the neatest -MJS) + if( !mDisallowCustom) { - // Update custom curve (so it's there for next time) - //(done in a hurry, may not be the neatest -MJS) - if( (mDirty == true) & (drawMode == true) ) + if ( mDirty && drawMode ) { int i, j; int numPoints = mLogEnvelope->GetNumberOfPoints(); @@ -2829,22 +2864,13 @@ delete [] value; Select( (int) mCurves.GetCount()-1 ); } + SaveCurves(); } - SaveCurves(); - - if(mLogEnvelope) - delete mLogEnvelope; - mLogEnvelope = NULL; - if(mLinEnvelope) - delete mLinEnvelope; - mLinEnvelope = NULL; - mPanel = NULL; - - EndModal(true); + Finish(true); } else { - event.Skip(); + event.Skip(false); } } Index: Equalization.h =================================================================== RCS file: /cvsroot/audacity/audacity-src/src/effects/Equalization.h,v retrieving revision 1.42 retrieving revision 1.43 diff -u -d -r1.42 -r1.43 --- Equalization.h 7 Aug 2009 15:32:57 -0000 1.42 +++ Equalization.h 17 Aug 2009 10:45:55 -0000 1.43 @@ -260,6 +260,9 @@ void spline(double x[], double y[], int n, double y2[]); double splint(double x[], double y[], int n, double y2[], double xr); void LayoutEQSliders(); + bool SaveAs(); + void RevertCustom(); + void Finish(bool ok); // XMLTagHandler callback methods for loading and saving bool HandleXMLTag(const wxChar *tag, const wxChar **attrs); @@ -352,6 +355,7 @@ wxCheckBox *mGridOnOff; EQCurveArray mCurves; + EQCurve mCustomBackup; private: DECLARE_EVENT_TABLE() ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Audacity-cvs mailing list Audacity-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/audacity-cvs