mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-23 10:11:08 +00:00
title-clip: Return default GESTitleSource value if no child set yet
In get_property we should return the default values if we have not created any GESTitleSource yet (instead of segfaulting). And fix GESTitleSource default values! Reviewed-by: Thibault Saunier <thibault.saunier@collabora.com> Differential Revision: https://phabricator.freedesktop.org/D737
This commit is contained in:
parent
7211e6982f
commit
3ffdad6db8
3 changed files with 36 additions and 25 deletions
|
@ -70,44 +70,32 @@ static void
|
|||
ges_title_clip_get_property (GObject * object, guint property_id,
|
||||
GValue * value, GParamSpec * pspec)
|
||||
{
|
||||
GESTimelineElement *child, *tmpsrc = NULL;
|
||||
GESTitleClipPrivate *priv = GES_TITLE_CLIP (object)->priv;
|
||||
|
||||
if (!priv->track_titles)
|
||||
child = tmpsrc = GES_TIMELINE_ELEMENT (ges_title_source_new ());
|
||||
else
|
||||
child = priv->track_titles->data;
|
||||
|
||||
switch (property_id) {
|
||||
/* Falltrough all over */
|
||||
case PROP_TEXT:
|
||||
ges_track_element_get_child_property (priv->track_titles->data, "text",
|
||||
value);
|
||||
break;
|
||||
case PROP_FONT_DESC:
|
||||
ges_track_element_get_child_property (priv->track_titles->data,
|
||||
"font-desc", value);
|
||||
break;
|
||||
case PROP_HALIGNMENT:
|
||||
ges_track_element_get_child_property (priv->track_titles->data,
|
||||
"halignment", value);
|
||||
break;
|
||||
case PROP_VALIGNMENT:
|
||||
ges_track_element_get_child_property (priv->track_titles->data,
|
||||
"valignment", value);
|
||||
break;
|
||||
case PROP_COLOR:
|
||||
ges_track_element_get_child_property (priv->track_titles->data, "color",
|
||||
value);
|
||||
break;
|
||||
case PROP_BACKGROUND:
|
||||
ges_track_element_get_child_property (priv->track_titles->data,
|
||||
"foreground-color", value);
|
||||
break;
|
||||
case PROP_XPOS:
|
||||
ges_track_element_get_child_property (priv->track_titles->data, "xpos",
|
||||
value);
|
||||
break;
|
||||
case PROP_YPOS:
|
||||
ges_track_element_get_child_property (priv->track_titles->data, "ypos",
|
||||
value);
|
||||
ges_timeline_element_get_child_property (child, pspec->name, value);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
}
|
||||
|
||||
if (tmpsrc)
|
||||
g_object_unref (tmpsrc);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -93,6 +93,9 @@
|
|||
#include "ges-title-source.h"
|
||||
#include "ges-video-test-source.h"
|
||||
|
||||
#define DEFAULT_TEXT ""
|
||||
#define DEFAULT_FONT_DESC "Serif 36"
|
||||
|
||||
G_DEFINE_TYPE (GESTitleSource, ges_title_source, GES_TYPE_VIDEO_SOURCE);
|
||||
|
||||
struct _GESTitleSourcePrivate
|
||||
|
@ -171,8 +174,8 @@ ges_title_source_init (GESTitleSource * self)
|
|||
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
|
||||
GES_TYPE_TITLE_SOURCE, GESTitleSourcePrivate);
|
||||
|
||||
self->priv->text = NULL;
|
||||
self->priv->font_desc = NULL;
|
||||
self->priv->text = g_strdup (DEFAULT_TEXT);
|
||||
self->priv->font_desc = g_strdup (DEFAULT_FONT_DESC);
|
||||
self->priv->text_el = NULL;
|
||||
self->priv->halign = DEFAULT_HALIGNMENT;
|
||||
self->priv->valign = DEFAULT_VALIGNMENT;
|
||||
|
|
|
@ -52,3 +52,23 @@ class TestCopyPaste(unittest.TestCase):
|
|||
|
||||
copy.paste(10)
|
||||
self.assertEqual(len(self.layer.get_clips()), 1)
|
||||
|
||||
def testCopyPasteTitleClip(self):
|
||||
clip1 = GES.TitleClip.new()
|
||||
clip1.props.duration = 10
|
||||
|
||||
self.layer.add_clip(clip1)
|
||||
self.assertEqual(len(clip1.get_children(False)), 1)
|
||||
|
||||
copy = clip1.copy(True)
|
||||
self.assertEqual(len(self.layer.get_clips()), 1)
|
||||
|
||||
copy.paste(10)
|
||||
self.assertEqual(len(self.layer.get_clips()), 2)
|
||||
|
||||
|
||||
class TestTitleClip(unittest.TestCase):
|
||||
def testGetPropertyNotInTrack(self):
|
||||
title_clip = GES.TitleClip.new()
|
||||
self.assertEqual(title_clip.props.text, "")
|
||||
self.assertEqual(title_clip.props.font_desc, "Serif 36")
|
||||
|
|
Loading…
Reference in a new issue