From 4b0fc9317bd534520e06cadd2c88db8cb318d516 Mon Sep 17 00:00:00 2001 From: Francesco Ceruti Date: Sun, 22 May 2016 16:08:11 +0200 Subject: [PATCH] Removed deprecated GObject.init_threads call. Fix: A ton of threading problems caused by GObject.init_threads call; Fix: minor fixes. --- lisp/backends/gst/backend.py | 7 ++----- lisp/layouts/cart_layout/cue_widget.py | 8 +++----- lisp/layouts/cart_layout/layout.py | 6 ++++++ lisp/layouts/cart_layout/page_widget.py | 23 +++++++++++++---------- lisp/layouts/list_layout/cue_list_view.py | 5 +++++ 5 files changed, 29 insertions(+), 20 deletions(-) diff --git a/lisp/backends/gst/backend.py b/lisp/backends/gst/backend.py index b4d39f25c..d926d7ed1 100644 --- a/lisp/backends/gst/backend.py +++ b/lisp/backends/gst/backend.py @@ -19,7 +19,7 @@ from lisp.backends.base.backend import Backend as BaseBackend from lisp.backends.gst import elements, settings -from lisp.backends.gst.gi_repository import Gst, GObject +from lisp.backends.gst.gi_repository import Gst from lisp.backends.gst.gst_cue_factories import register_factories from lisp.backends.gst.gst_media_settings import GstMediaSettings from lisp.backends.gst.gst_settings import GstSettings @@ -34,10 +34,7 @@ class Backend(BaseBackend): def __init__(self): - """Startup GStreamer and GObject.""" - - # Initialize GStreamer and GObject - GObject.threads_init() + # Initialize GStreamer Gst.init(None) # Register GStreamer settings widgets diff --git a/lisp/layouts/cart_layout/cue_widget.py b/lisp/layouts/cart_layout/cue_widget.py index a636acc68..5787a3f9f 100644 --- a/lisp/layouts/cart_layout/cue_widget.py +++ b/lisp/layouts/cart_layout/cue_widget.py @@ -88,13 +88,10 @@ def __init__(self, cue, **kwargs): self.seekSlider.setFocusPolicy(Qt.NoFocus) self.seekSlider.setVisible(False) - # Volume percentage slider (0%-200%) self.volumeSlider = QClickSlider(self.nameButton) - #self.volumeSlider.setTickPosition(QClickSlider.TicksBothSides) self.volumeSlider.setOrientation(Qt.Vertical) self.volumeSlider.setFocusPolicy(Qt.NoFocus) self.volumeSlider.setRange(-500, 0) - #self.volumeSlider.setTickInterval(50) # 0%, 50%, 100%, 150%, 200% self.volumeSlider.setTracking(True) self.volumeSlider.valueChanged.connect(self._change_volume, Qt.DirectConnection) @@ -229,7 +226,8 @@ def _set_cue(self, cue): Connection.QtQueued) if isinstance(cue, MediaCue): - self.cue.media.changed('pipe').connect(self._media_updated) + self.cue.media.changed('pipe').connect(self._media_updated, + Connection.QtQueued) self.cue.paused.connect(self.dbMeter.reset, Connection.QtQueued) self.cue.stopped.connect(self.dbMeter.reset, Connection.QtQueued) @@ -247,7 +245,7 @@ def _set_cue(self, cue): self.cue.end.connect(self._status_stopped, Connection.QtQueued) self._cue_time = CueTime(self.cue) - self._cue_time.notify.connect(self._update_time) + self._cue_time.notify.connect(self._update_time, Connection.QtQueued) self._update_name(cue.name) self._update_style(cue.stylesheet) diff --git a/lisp/layouts/cart_layout/layout.py b/lisp/layouts/cart_layout/layout.py index b5c267bdd..09399a7c1 100644 --- a/lisp/layouts/cart_layout/layout.py +++ b/lisp/layouts/cart_layout/layout.py @@ -73,6 +73,7 @@ def __init__(self, cue_model, **kwargs): self._model_adapter.item_added.connect(self.__cue_added, Connection.QtQueued) self._model_adapter.item_removed.connect(self.__cue_removed, Connection.QtQueued) self._model_adapter.item_moved.connect(self.__cue_moved, Connection.QtQueued) + self._model_adapter.model_reset.connect(self.__model_reset) # Add layout-specific menus self.new_page_action = QAction(self) @@ -417,3 +418,8 @@ def __cue_moved(self, old_index, new_index): else: widget = self.__pages[o_page].take_widget(o_row, o_column) self.__pages[n_page].add_widget(widget, n_row, n_column) + + def __model_reset(self): + self.__context_widget = None + for page in self.__pages: + page.reset() diff --git a/lisp/layouts/cart_layout/page_widget.py b/lisp/layouts/cart_layout/page_widget.py index d54166881..b9b0437d6 100644 --- a/lisp/layouts/cart_layout/page_widget.py +++ b/lisp/layouts/cart_layout/page_widget.py @@ -91,16 +91,8 @@ def index(self, widget): def widgets(self): return iter(self.__widgets.values()) - def _check_index(self, row, column): - if not isinstance(row, int): - raise TypeError('rows index must be integers, not {}' - .format(row.__class__.__name__)) - if not isinstance(column, int): - raise TypeError('columns index must be integers, not {}' - .format(column.__class__.__name__)) - - if not 0 <= row < self.__rows or not 0 <= column < self.__columns: - raise IndexError('index out of bound {}'.format((row, column))) + def reset(self): + self.__widgets.clear() def dragEnterEvent(self, event): if event.mimeData().hasText(): @@ -135,6 +127,17 @@ def dragMoveEvent(self, event): else: event.ignore() + def _check_index(self, row, column): + if not isinstance(row, int): + raise TypeError('rows index must be integers, not {}' + .format(row.__class__.__name__)) + if not isinstance(column, int): + raise TypeError('columns index must be integers, not {}' + .format(column.__class__.__name__)) + + if not 0 <= row < self.__rows or not 0 <= column < self.__columns: + raise IndexError('index out of bound {}'.format((row, column))) + def _event_index(self, event): # Margins and spacings are equals space = self.layout().horizontalSpacing() diff --git a/lisp/layouts/list_layout/cue_list_view.py b/lisp/layouts/list_layout/cue_list_view.py index 39f7e6ff0..368ac1098 100644 --- a/lisp/layouts/list_layout/cue_list_view.py +++ b/lisp/layouts/list_layout/cue_list_view.py @@ -49,6 +49,7 @@ def __init__(self, cue_model, parent=None): self._model.item_added.connect(self.__cue_added, Connection.QtQueued) self._model.item_moved.connect(self.__cue_moved, Connection.QtQueued) self._model.item_removed.connect(self.__cue_removed, Connection.QtQueued) + self._model.model_reset.connect(self.__model_reset) self._drag_item = None self._drag_start = None self.__item_moving = False @@ -148,6 +149,10 @@ def __cue_removed(self, cue): index -= 1 self.setCurrentIndex(self.model().index(index, 0)) + def __model_reset(self): + self.reset() + self.clear() + def __init_item(self, item, cue): item.name_column = CueListView.H_NAMES.index('Cue') for index, widget in enumerate(CueListView.H_WIDGETS):