Check return values (e.g. indexOf)
This commit is contained in:
parent
ef5b16556b
commit
4bd8a596f1
@ -77,7 +77,9 @@ class BaseCompletionModel(QStandardItemModel):
|
|||||||
qt_ensure_valid(index)
|
qt_ensure_valid(index)
|
||||||
haystack = self.data(index)
|
haystack = self.data(index)
|
||||||
marks = self._get_marks(needle, haystack)
|
marks = self._get_marks(needle, haystack)
|
||||||
self.setData(index, marks, Role.marks)
|
ok = self.setData(index, marks, Role.marks)
|
||||||
|
if not ok:
|
||||||
|
raise ValueError("Error while setting data!")
|
||||||
|
|
||||||
def new_category(self, name, sort=None):
|
def new_category(self, name, sort=None):
|
||||||
"""Add a new category to the model.
|
"""Add a new category to the model.
|
||||||
|
@ -88,7 +88,10 @@ class SettingOptionCompletionModel(BaseCompletionModel):
|
|||||||
val = config.get(section, option, raw=True)
|
val = config.get(section, option, raw=True)
|
||||||
idx = item.index()
|
idx = item.index()
|
||||||
qt_ensure_valid(idx)
|
qt_ensure_valid(idx)
|
||||||
self.setData(idx, val, Qt.DisplayRole)
|
ok = self.setData(idx, val, Qt.DisplayRole)
|
||||||
|
if not ok:
|
||||||
|
raise ValueError("Setting data failed! (section: {}, option: {}, "
|
||||||
|
"value: {})".format(section, option, val))
|
||||||
|
|
||||||
|
|
||||||
class SettingValueCompletionModel(BaseCompletionModel):
|
class SettingValueCompletionModel(BaseCompletionModel):
|
||||||
@ -127,7 +130,10 @@ class SettingValueCompletionModel(BaseCompletionModel):
|
|||||||
value = '""'
|
value = '""'
|
||||||
idx = self.cur_item.index()
|
idx = self.cur_item.index()
|
||||||
qt_ensure_valid(idx)
|
qt_ensure_valid(idx)
|
||||||
self.setData(idx, value, Qt.DisplayRole)
|
ok = self.setData(idx, value, Qt.DisplayRole)
|
||||||
|
if not ok:
|
||||||
|
raise ValueError("Setting data failed! (section: {}, option: {}, "
|
||||||
|
"value: {})".format(section, option, value))
|
||||||
|
|
||||||
|
|
||||||
class CommandCompletionModel(BaseCompletionModel):
|
class CommandCompletionModel(BaseCompletionModel):
|
||||||
|
@ -342,7 +342,10 @@ class TabbedBrowser(TabWidget):
|
|||||||
Args:
|
Args:
|
||||||
tab: The tab where the signal belongs to.
|
tab: The tab where the signal belongs to.
|
||||||
"""
|
"""
|
||||||
self.setTabIcon(self.indexOf(tab), EmptyTabIcon())
|
idx = self.indexOf(tab)
|
||||||
|
if idx == -1:
|
||||||
|
raise ValueError("Tab {} not found!".format(tab))
|
||||||
|
self.setTabIcon(idx, EmptyTabIcon())
|
||||||
|
|
||||||
@pyqtSlot(WebView, str)
|
@pyqtSlot(WebView, str)
|
||||||
def on_title_changed(self, tab, text):
|
def on_title_changed(self, tab, text):
|
||||||
@ -356,7 +359,10 @@ class TabbedBrowser(TabWidget):
|
|||||||
"""
|
"""
|
||||||
log.webview.debug("title changed to '{}'".format(text))
|
log.webview.debug("title changed to '{}'".format(text))
|
||||||
if text:
|
if text:
|
||||||
self.setTabText(self.indexOf(tab), text)
|
idx = self.indexOf(tab)
|
||||||
|
if idx == -1:
|
||||||
|
raise ValueError("Tab {} not found!".format(tab))
|
||||||
|
self.setTabText(idx, text)
|
||||||
else:
|
else:
|
||||||
log.webview.debug("ignoring title change")
|
log.webview.debug("ignoring title change")
|
||||||
|
|
||||||
@ -369,6 +375,8 @@ class TabbedBrowser(TabWidget):
|
|||||||
url: The new URL.
|
url: The new URL.
|
||||||
"""
|
"""
|
||||||
idx = self.indexOf(tab)
|
idx = self.indexOf(tab)
|
||||||
|
if idx == -1:
|
||||||
|
raise ValueError("Tab {} not found!".format(tab))
|
||||||
if not self.tabText(idx):
|
if not self.tabText(idx):
|
||||||
self.setTabText(idx, url)
|
self.setTabText(idx, url)
|
||||||
|
|
||||||
@ -383,7 +391,10 @@ class TabbedBrowser(TabWidget):
|
|||||||
"""
|
"""
|
||||||
if not config.get('tabbar', 'show-favicons'):
|
if not config.get('tabbar', 'show-favicons'):
|
||||||
return
|
return
|
||||||
self.setTabIcon(self.indexOf(tab), tab.icon())
|
idx = self.indexOf(tab)
|
||||||
|
if idx == -1:
|
||||||
|
raise ValueError("Tab {} not found!".format(tab))
|
||||||
|
self.setTabIcon(idx, tab.icon())
|
||||||
|
|
||||||
@pyqtSlot(str)
|
@pyqtSlot(str)
|
||||||
def on_mode_left(self, mode):
|
def on_mode_left(self, mode):
|
||||||
|
Loading…
Reference in New Issue
Block a user