[pitivi] project: Avoid asset-added being fired twice
- From: Alexandru Băluț <alexbalut src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi] project: Avoid asset-added being fired twice
- Date: Sat, 16 Apr 2016 14:24:36 +0000 (UTC)
commit cd82c3c06138cec1186c7059733b71a9597c67e3
Author: Alexandru Băluț <alexandru balut gmail com>
Date: Mon Apr 4 00:34:30 2016 +0200
project: Avoid asset-added being fired twice
Differential Revision: https://phabricator.freedesktop.org/D865
pitivi/project.py | 8 ++------
tests/test_project.py | 30 ++++++++++++++++++++++++++++++
2 files changed, 32 insertions(+), 6 deletions(-)
---
diff --git a/pitivi/project.py b/pitivi/project.py
index 9cc3308..05c6ad0 100644
--- a/pitivi/project.py
+++ b/pitivi/project.py
@@ -997,7 +997,7 @@ class Project(Loggable, GES.Project):
self.loading_assets = []
def __assetTranscodingCancelledCb(self, unused_proxy_manager, asset):
- self.__setProxy(asset, None, emit_asset_added=False)
+ self.__setProxy(asset, None)
self.__updateAssetLoadingProgress()
def __proxyErrorCb(self, unused_proxy_manager, asset, proxy,
@@ -1032,7 +1032,7 @@ class Project(Loggable, GES.Project):
def __proxyReadyCb(self, unused_proxy_manager, asset, proxy):
self.__setProxy(asset, proxy)
- def __setProxy(self, asset, proxy, emit_asset_added=True):
+ def __setProxy(self, asset, proxy):
asset.creation_progress = 100
if proxy:
proxy.ready = False
@@ -1047,10 +1047,6 @@ class Project(Loggable, GES.Project):
if proxy:
self.add_asset(proxy)
- elif emit_asset_added:
- self.emit("asset-added", asset)
-
- if proxy:
self.loading_assets.append(proxy)
self.__updateAssetLoadingProgress()
diff --git a/tests/test_project.py b/tests/test_project.py
index f5f15ad..b84c8e0 100644
--- a/tests/test_project.py
+++ b/tests/test_project.py
@@ -27,6 +27,7 @@ from unittest import TestCase
from gi.repository import GES
from gi.repository import Gst
+from pitivi.application import Pitivi
from pitivi.project import Project
from pitivi.project import ProjectManager
from pitivi.utils.misc import uri_is_reachable
@@ -349,6 +350,35 @@ class TestProjectLoading(common.TestCase):
finally:
os.remove(xges_path)
+ def test_asset_added_signal(self):
+ app = Pitivi()
+ app._startupCb(app)
+ self.assertTrue(app.project_manager.newBlankProject())
+
+ project = app.project_manager.current_project
+ proxy_manager = app.proxy_manager
+
+ mainloop = common.create_main_loop()
+
+ def asset_added_cb(project, asset, assets):
+ assets.append(asset)
+
+ assets = []
+ project.connect("asset-added", asset_added_cb, assets)
+
+ def proxy_ready_cb(unused_proxy_manager, asset, proxy):
+ mainloop.quit()
+
+ proxy_manager.connect("proxy-ready", proxy_ready_cb)
+
+
+ uris = [common.getSampleUri("tears_of_steel.webm")]
+ project.addUris(uris)
+
+ mainloop.run()
+
+ self.assertEqual(len(assets), 1, assets)
+
class TestProjectSettings(common.TestCase):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]