Fix CourseID::ToCourse to use its cache correctly and check whether the path is empty before prepending a slash.
This commit is contained in:
+19
-8
@@ -552,20 +552,31 @@ void CourseID::FromCourse( const Course *p )
|
|||||||
|
|
||||||
Course *CourseID::ToCourse() const
|
Course *CourseID::ToCourse() const
|
||||||
{
|
{
|
||||||
|
Course *pCourse = NULL;
|
||||||
|
if(m_Cache.Get(&pCourse))
|
||||||
|
{
|
||||||
|
return pCourse;
|
||||||
|
}
|
||||||
|
if(!sPath.empty())
|
||||||
|
{
|
||||||
// HACK for backwards compatibility:
|
// HACK for backwards compatibility:
|
||||||
// Re-add the leading "/". 2005/05/21 file layer changes added a leading slash.
|
// Re-add the leading "/". 2005/05/21 file layer changes added a leading slash.
|
||||||
RString sPath2 = sPath;
|
RString slash_path = sPath;
|
||||||
if( sPath2.Left(1) != "/" )
|
if(slash_path.Left(1) != "/")
|
||||||
sPath2 = "/" + sPath2;
|
{
|
||||||
|
slash_path = "/" + slash_path;
|
||||||
|
}
|
||||||
|
|
||||||
Course *pCourse = NULL;
|
if(pCourse == NULL)
|
||||||
if( m_Cache.Get(&pCourse) )
|
{
|
||||||
return pCourse;
|
pCourse = SONGMAN->GetCourseFromPath(slash_path);
|
||||||
if( pCourse == NULL && !sPath2.empty() )
|
}
|
||||||
pCourse = SONGMAN->GetCourseFromPath( sPath2 );
|
}
|
||||||
|
|
||||||
if( pCourse == NULL && !sFullTitle.empty() )
|
if( pCourse == NULL && !sFullTitle.empty() )
|
||||||
|
{
|
||||||
pCourse = SONGMAN->GetCourseFromName( sFullTitle );
|
pCourse = SONGMAN->GetCourseFromName( sFullTitle );
|
||||||
|
}
|
||||||
m_Cache.Set( pCourse );
|
m_Cache.Set( pCourse );
|
||||||
|
|
||||||
return pCourse;
|
return pCourse;
|
||||||
|
|||||||
Reference in New Issue
Block a user