Check model rowCount before accessing to data.

This commit is contained in:
Luis Ángel San Martín
2016-04-13 22:51:15 +02:00
parent cfece24a3f
commit 4ef185c885
2 changed files with 5 additions and 2 deletions

View File

@ -194,7 +194,7 @@ void GridComicsView::updateBackgroundConfig()
//backgroun image configuration //backgroun image configuration
bool useBackgroundImage = settings->value(USE_BACKGROUND_IMAGE_IN_GRID_VIEW, true).toBool(); bool useBackgroundImage = settings->value(USE_BACKGROUND_IMAGE_IN_GRID_VIEW, true).toBool();
if(useBackgroundImage) if(useBackgroundImage && this->model->rowCount() > 0)
{ {
float opacity = settings->value(OPACITY_BACKGROUND_IMAGE_IN_GRID_VIEW, 0.2).toFloat(); float opacity = settings->value(OPACITY_BACKGROUND_IMAGE_IN_GRID_VIEW, 0.2).toFloat();
float blurRadius = settings->value(BLUR_RADIUS_BACKGROUND_IMAGE_IN_GRID_VIEW, 75).toInt(); float blurRadius = settings->value(BLUR_RADIUS_BACKGROUND_IMAGE_IN_GRID_VIEW, 75).toInt();

View File

@ -67,7 +67,10 @@ void InfoComicsView::setModel(ComicModel *model)
_selectionModel = new QItemSelectionModel(model);*/ _selectionModel = new QItemSelectionModel(model);*/
ctxt->setContextProperty("comicsList", model); ctxt->setContextProperty("comicsList", model);
if(model->rowCount()>0)
ctxt->setContextProperty("backgroundImage", this->model->data(this->model->index(0, 0), ComicModel::CoverPathRole)); ctxt->setContextProperty("backgroundImage", this->model->data(this->model->index(0, 0), ComicModel::CoverPathRole));
else
ctxt->setContextProperty("backgroundImage", QUrl());
/*ctxt->setContextProperty("comicsSelection", _selectionModel); /*ctxt->setContextProperty("comicsSelection", _selectionModel);
ctxt->setContextProperty("contextMenuHelper",this); ctxt->setContextProperty("contextMenuHelper",this);