diff --git a/src/CourseUtil.cpp b/src/CourseUtil.cpp index 5c67882ed6..f2a53a8752 100644 --- a/src/CourseUtil.cpp +++ b/src/CourseUtil.cpp @@ -552,20 +552,31 @@ void CourseID::FromCourse( const Course *p ) Course *CourseID::ToCourse() const { - // HACK for backwards compatibility: - // Re-add the leading "/". 2005/05/21 file layer changes added a leading slash. - RString sPath2 = sPath; - if( sPath2.Left(1) != "/" ) - sPath2 = "/" + sPath2; - Course *pCourse = NULL; - if( m_Cache.Get(&pCourse) ) + if(m_Cache.Get(&pCourse)) + { return pCourse; - if( pCourse == NULL && !sPath2.empty() ) - pCourse = SONGMAN->GetCourseFromPath( sPath2 ); + } + if(!sPath.empty()) + { + // HACK for backwards compatibility: + // Re-add the leading "/". 2005/05/21 file layer changes added a leading slash. + RString slash_path = sPath; + if(slash_path.Left(1) != "/") + { + slash_path = "/" + slash_path; + } + + if(pCourse == NULL) + { + pCourse = SONGMAN->GetCourseFromPath(slash_path); + } + } if( pCourse == NULL && !sFullTitle.empty() ) + { pCourse = SONGMAN->GetCourseFromName( sFullTitle ); + } m_Cache.Set( pCourse ); return pCourse;