Commit 1dfa3655 authored by Samikshan Bairagya's avatar Samikshan Bairagya
Browse files

Fixed crash that occured when changes to a course was cancelled in

the "Course Editor Mode".
parent 160d3790
......@@ -197,6 +197,7 @@ void ResourceManager::reloadCourseOrSkeleton(Course *courseOrSkeleton)
//TODO better add a check if this is contained in the course list
// to catch possible errors
KUrl file = courseOrSkeleton->file();
m_loadedResources.removeOne(courseOrSkeleton->file().toLocalFile());
removeCourse(courseOrSkeleton);
addCourse(file);
} else {
......@@ -322,7 +323,6 @@ void ResourceManager::removeCourse(Course *course)
if (m_courseResources[course->language()->id()].at(index)->course() == course) {
emit courseResourceAboutToBeRemoved(index);
m_courseResources[course->language()->id()].removeAt(index);
emit courseResourceRemoved();
course->deleteLater();
return;
}
......
......@@ -162,7 +162,6 @@ signals:
void languageResourceAboutToBeRemoved(int);
void courseResourceAdded();
void courseResourceAboutToBeAdded(CourseResource*,int);
void courseResourceRemoved();
void courseResourceAboutToBeRemoved(int);
void skeletonAdded();
void skeletonAboutToBeAdded(Course*,int);
......
......@@ -68,8 +68,6 @@ void CourseModel::setResourceManager(ResourceManager *resourceManager)
SLOT(onCourseResourceAdded()));
connect(m_resourceManager, SIGNAL(courseResourceAboutToBeRemoved(int)),
SLOT(onCourseResourceAboutToBeRemoved(int)));
connect(m_resourceManager, SIGNAL(courseResourceRemoved()),
SLOT(onCourseResourceRemoved()));
updateResources();
}
......@@ -182,6 +180,9 @@ void CourseModel::onCourseResourceAdded()
void CourseModel::onCourseResourceAboutToBeRemoved(int index)
{
if (!m_language) {
return;
}
CourseResource *originalResource = m_resourceManager->courseResources(m_language).at(index);
int modelIndex = m_resources.indexOf(originalResource);
......@@ -191,10 +192,6 @@ void CourseModel::onCourseResourceAboutToBeRemoved(int index)
}
beginRemoveRows(QModelIndex(), modelIndex, modelIndex);
m_resources.removeAt(modelIndex);
}
void CourseModel::onCourseResourceRemoved()
{
endRemoveRows();
}
......
......@@ -73,7 +73,6 @@ private slots:
void onCourseResourceAboutToBeAdded(CourseResource *resource, int index);
void onCourseResourceAdded();
void onCourseResourceAboutToBeRemoved(int index);
void onCourseResourceRemoved();
void emitCourseChanged(int row);
private:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment