Activate tool buttons if a list item is selected.
[dorian] / bookview.cpp
index d240070..fda10b9 100644 (file)
@@ -314,16 +314,18 @@ void BookView::paintEvent(QPaintEvent *e)
         int bookmarkPos = (int)((qreal)height * (qreal)b.pos);
         painter.drawPixmap(2, bookmarkPos - scrollPos.y(), bookmarkPixmap);
     }
-    QPen pen(Qt::gray);
-    pen.setStyle(Qt::DotLine);
-    pen.setWidth(3);
-    painter.setPen(pen);
-    if (contentIndex > 0) {
-        painter.drawLine(0, -scrollPos.y(), width(), -scrollPos.y());
-    }
-    if (contentIndex < (mBook->parts.size() - 1)) {
-        int h = contentsHeight - scrollPos.y() - 1;
-        painter.drawLine(0, h, width(), h);
+    if (mBook) {
+        QPen pen(Qt::gray);
+        pen.setStyle(Qt::DotLine);
+        pen.setWidth(3);
+        painter.setPen(pen);
+        if (contentIndex > 0) {
+            painter.drawLine(0, -scrollPos.y(), width(), -scrollPos.y());
+        }
+        if (contentIndex < (mBook->parts.size() - 1)) {
+            int h = contentsHeight - scrollPos.y() - 1;
+            painter.drawLine(0, h, width(), h);
+        }
     }
 }