This code worked just fine some months ago (maybe half year), and now it's not working. Why could it be? Message error is ''NoneType' object has no attribute 'style'' from line 12.

Qt Code:
  1. def paint(self, painter, option, index):
  2. if not index.isValid():
  3. return
  4. painter.translate(0, 0)
  5. options = QStyleOptionViewItemV4(option)
  6. self.initStyleOption(options, index)
  7. painter.save()
  8. painter.setRenderHint(QPainter.Antialiasing, True)
  9. doc = QTextDocument()
  10. doc.setHtml(options.text)
  11. options.text = ""
  12. options.widget.style().drawControl(QStyle.CE_ItemViewItem, options, painter, options.widget) #<---ERROR
  13. painter.translate(options.rect.left() + self.sizeDp(index) + 3, options.rect.top()) #paint text right after the dp + 3pixels
  14. rect = QRectF(0, 0, options.rect.width(), options.rect.height())
  15. doc.drawContents(painter, rect)
  16. painter.restore()
To copy to clipboard, switch view to plain text mode 

Why could this be happening?