Skip to content

Commit

Permalink
Removed deprecated GObject.init_threads call.
Browse files Browse the repository at this point in the history
Fix: A ton of threading problems caused by GObject.init_threads call;
Fix: minor fixes.
  • Loading branch information
FrancescoCeruti committed May 22, 2016
1 parent ed96bc0 commit 4b0fc93
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 20 deletions.
7 changes: 2 additions & 5 deletions lisp/backends/gst/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
8 changes: 3 additions & 5 deletions lisp/layouts/cart_layout/cue_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions lisp/layouts/cart_layout/layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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()
23 changes: 13 additions & 10 deletions lisp/layouts/cart_layout/page_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down Expand Up @@ -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()
Expand Down
5 changes: 5 additions & 0 deletions lisp/layouts/list_layout/cue_list_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit 4b0fc93

Please sign in to comment.