mirror of
https://github.com/Rafostar/clapper.git
synced 2025-08-31 00:11:59 +02:00
Drop all player signals on destroy
This commit is contained in:
@@ -146,25 +146,27 @@ var App = GObject.registerClass({
|
||||
this.player.connect('error', this._onPlayerError.bind(this));
|
||||
this.player.connect('state-changed', this._onPlayerStateChanged.bind(this));
|
||||
|
||||
this.player.widget.connect(
|
||||
this.player.connectWidget(
|
||||
'button-press-event', this._onPlayerButtonPressEvent.bind(this)
|
||||
);
|
||||
this.player.widget.connect(
|
||||
this.player.connectWidget(
|
||||
'scroll-event', this._onPlayerScrollEvent.bind(this)
|
||||
);
|
||||
this.player.widget.connect(
|
||||
this.player.connectWidget(
|
||||
'enter-notify-event', this._onPlayerEnterNotifyEvent.bind(this)
|
||||
);
|
||||
this.player.widget.connect(
|
||||
this.player.connectWidget(
|
||||
'leave-notify-event', this._onPlayerLeaveNotifyEvent.bind(this)
|
||||
);
|
||||
this.player.widget.connect(
|
||||
this.player.connectWidget(
|
||||
'motion-notify-event', this._onPlayerMotionNotifyEvent.bind(this)
|
||||
);
|
||||
this.playerRealizeSignal = this.player.widget.connect(
|
||||
|
||||
/* Widget signals that are disconnected after first run */
|
||||
this._playerRealizeSignal = this.player.widget.connect(
|
||||
'realize', this._onPlayerRealize.bind(this)
|
||||
);
|
||||
this.playerDrawSignal = this.player.widget.connect(
|
||||
this._playerDrawSignal = this.player.widget.connect(
|
||||
'draw', this._onPlayerDraw.bind(this)
|
||||
);
|
||||
|
||||
@@ -226,7 +228,7 @@ var App = GObject.registerClass({
|
||||
break;
|
||||
case Gdk.KEY_q:
|
||||
case Gdk.KEY_Q:
|
||||
this.quit();
|
||||
this.window.destroy();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -243,7 +245,7 @@ var App = GObject.registerClass({
|
||||
|
||||
_onPlayerRealize()
|
||||
{
|
||||
this.player.widget.disconnect(this.playerRealizeSignal);
|
||||
this.player.widget.disconnect(this._playerRealizeSignal);
|
||||
this.player.renderer.expose();
|
||||
|
||||
let display = this.player.widget.get_display();
|
||||
@@ -261,7 +263,7 @@ var App = GObject.registerClass({
|
||||
|
||||
_onPlayerDraw(self, data)
|
||||
{
|
||||
this.player.widget.disconnect(this.playerDrawSignal);
|
||||
this.player.widget.disconnect(this._playerDrawSignal);
|
||||
this.emit('ready', true);
|
||||
|
||||
if(this.playlist.length)
|
||||
|
@@ -38,6 +38,9 @@ class ClapperPlayer extends GstPlayer.Player
|
||||
this.dispatcher = dispatcher;
|
||||
this.renderer = renderer;
|
||||
|
||||
this._playerSignals = [];
|
||||
this._widgetSignals = [];
|
||||
|
||||
let config = this.get_config();
|
||||
|
||||
for(let setting of Object.keys(GSTPLAYER_DEFAULTS)) {
|
||||
@@ -65,7 +68,7 @@ class ClapperPlayer extends GstPlayer.Player
|
||||
this.connect('state-changed', this._onStateChanged.bind(this));
|
||||
this.connect('uri-loaded', this._onUriLoaded.bind(this));
|
||||
this.connect('end-of-stream', this._onStreamEnded.bind(this));
|
||||
this.widget.connect('destroy', this._onWidgetDestroy.bind(this));
|
||||
this.connectWidget('destroy', this._onWidgetDestroy.bind(this));
|
||||
}
|
||||
|
||||
set_media(source)
|
||||
@@ -169,6 +172,16 @@ class ClapperPlayer extends GstPlayer.Player
|
||||
pipeline.subtitle_font_desc = desc;
|
||||
}
|
||||
|
||||
connect(signal, fn)
|
||||
{
|
||||
this._playerSignals.push(super.connect(signal, fn));
|
||||
}
|
||||
|
||||
connectWidget(signal, fn)
|
||||
{
|
||||
this._widgetSignals.push(this.widget.connect(signal, fn));
|
||||
}
|
||||
|
||||
_onStateChanged(player, state)
|
||||
{
|
||||
this.state = state;
|
||||
@@ -202,6 +215,12 @@ class ClapperPlayer extends GstPlayer.Player
|
||||
|
||||
_onWidgetDestroy()
|
||||
{
|
||||
while(this._widgetSignals.length)
|
||||
this.widget.disconnect(this._widgetSignals.pop());
|
||||
|
||||
while(this._playerSignals.length)
|
||||
this.disconnect(this._playerSignals.pop());
|
||||
|
||||
if(this.state !== GstPlayer.PlayerState.STOPPED)
|
||||
this.stop();
|
||||
}
|
||||
|
Reference in New Issue
Block a user