From 4ef185c885788771e6b40fe336e1f08bded38a34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Wed, 13 Apr 2016 22:51:15 +0200 Subject: [PATCH] Check model rowCount before accessing to data. --- YACReaderLibrary/grid_comics_view.cpp | 2 +- YACReaderLibrary/info_comics_view.cpp | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/YACReaderLibrary/grid_comics_view.cpp b/YACReaderLibrary/grid_comics_view.cpp index 71dfa44d..a9c42d9d 100644 --- a/YACReaderLibrary/grid_comics_view.cpp +++ b/YACReaderLibrary/grid_comics_view.cpp @@ -194,7 +194,7 @@ void GridComicsView::updateBackgroundConfig() //backgroun image configuration 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 blurRadius = settings->value(BLUR_RADIUS_BACKGROUND_IMAGE_IN_GRID_VIEW, 75).toInt(); diff --git a/YACReaderLibrary/info_comics_view.cpp b/YACReaderLibrary/info_comics_view.cpp index 8ca046d3..c32d3d98 100644 --- a/YACReaderLibrary/info_comics_view.cpp +++ b/YACReaderLibrary/info_comics_view.cpp @@ -67,7 +67,10 @@ void InfoComicsView::setModel(ComicModel *model) _selectionModel = new QItemSelectionModel(model);*/ ctxt->setContextProperty("comicsList", model); - ctxt->setContextProperty("backgroundImage", this->model->data(this->model->index(0, 0), ComicModel::CoverPathRole)); + if(model->rowCount()>0) + ctxt->setContextProperty("backgroundImage", this->model->data(this->model->index(0, 0), ComicModel::CoverPathRole)); + else + ctxt->setContextProperty("backgroundImage", QUrl()); /*ctxt->setContextProperty("comicsSelection", _selectionModel); ctxt->setContextProperty("contextMenuHelper",this);