From b01e805aeb69b64ee42bebd15011d705f39efbc8 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 9 Jun 2018 10:25:34 +0530 Subject: [PATCH] Another column header context menu bug It should not be possible, since the library view has too many columns for outside column clicks, but apparently some people manage :) --- src/calibre/gui2/library/views.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/calibre/gui2/library/views.py b/src/calibre/gui2/library/views.py index ac7224a4c8..ec2c20e27a 100644 --- a/src/calibre/gui2/library/views.py +++ b/src/calibre/gui2/library/views.py @@ -468,12 +468,13 @@ class BooksView(QTableView): # {{{ col = self.column_map[idx] name = unicode(self.model().headerData(idx, Qt.Horizontal, Qt.DisplayRole) or '') view.column_header_context_menu = self.create_context_menu(col, name, view) - if self.is_library_view: + has_context_menu = hasattr(view, 'column_header_context_menu') + if self.is_library_view and has_context_menu: view.column_header_context_menu.addSeparator() view.column_header_context_menu.addAction( _('Un-split the book list') if self.pin_view.isVisible() else _('Split the book list'), partial(self.column_header_context_handler, action='split', column=col or 'title')) - if hasattr(view, 'column_header_context_menu'): + if has_context_menu: view.column_header_context_menu.popup(view.column_header.mapToGlobal(pos)) # }}}