[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] /srv/bzr/gnash/trunk r10736: Continue to parse the next t
From: |
Benjamin Wolsey |
Subject: |
[Gnash-commit] /srv/bzr/gnash/trunk r10736: Continue to parse the next tag after a parsing exception. |
Date: |
Mon, 23 Mar 2009 16:31:40 +0100 |
User-agent: |
Bazaar (1.5) |
------------------------------------------------------------
revno: 10736
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Mon 2009-03-23 16:31:40 +0100
message:
Continue to parse the next tag after a parsing exception.
modified:
libcore/MovieClip.cpp
libcore/parser/SWFMovieDefinition.cpp
libcore/parser/sprite_definition.cpp
------------------------------------------------------------
revno: 10735.1.1
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Mon 2009-03-23 08:40:22 +0100
message:
Rearrange function.
modified:
libcore/MovieClip.cpp
------------------------------------------------------------
revno: 10735.1.2
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Mon 2009-03-23 13:51:41 +0100
message:
Fix awful indentation in sprite_definition, don't stop parsing completely
when we hit a parsing exception.
modified:
libcore/parser/SWFMovieDefinition.cpp
libcore/parser/sprite_definition.cpp
------------------------------------------------------------
revno: 10735.1.3
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Mon 2009-03-23 15:34:35 +0100
message:
Comments.
modified:
libcore/parser/SWFMovieDefinition.cpp
=== modified file 'libcore/MovieClip.cpp'
--- a/libcore/MovieClip.cpp 2009-03-19 23:14:43 +0000
+++ b/libcore/MovieClip.cpp 2009-03-23 07:40:22 +0000
@@ -1588,54 +1588,44 @@
character* existing_char = dlist.get_character_at_depth(tag->getDepth());
- if (existing_char)
- {
- // if the existing character is not a shape, move it instead of replace
- if ( existing_char->isActionScriptReferenceable() )
- {
- move_display_object(tag, dlist);
- return;
- }
- else
- {
- boost::intrusive_ptr<character> ch =
- cdef->createDisplayObject(this, tag->getID());
-
- // TODO: check if we can drop this for REPLACE!
- // should we rename the character when it's REPLACE tag?
- if(tag->hasName())
- {
- ch->set_name(tag->getName());
- }
- else if(ch->wantsInstanceName())
- {
- std::string instance_name = getNextUnnamedInstanceName();
- ch->set_name(instance_name);
- }
- if(tag->hasRatio())
- {
- ch->set_ratio(tag->getRatio());
- }
- if(tag->hasCxform())
- {
- ch->set_cxform(tag->getCxform());
- }
- if(tag->hasMatrix())
- {
- ch->setMatrix(tag->getMatrix(), true); // update caches
- }
-
- // use SWFMatrix from the old character if tag doesn't provide one.
- dlist.replace_character(ch.get(), tag->getDepth(),
- !tag->hasCxform(),
- !tag->hasMatrix());
- }
- }
- else // non-existing character
- {
+ if (!existing_char) {
log_error(_("MovieClip::replace_display_object: could not "
- "find any character at depth %d"), tag->getDepth());
- }
+ "find any character at depth %d"), tag->getDepth());
+ return;
+ }
+
+ // if the existing character is not a shape, move it instead
+ // of replacing.
+ if (existing_char->isActionScriptReferenceable()) {
+ move_display_object(tag, dlist);
+ return;
+ }
+
+ boost::intrusive_ptr<character> ch =
+ cdef->createDisplayObject(this, tag->getID());
+
+ // TODO: check if we can drop this for REPLACE!
+ // should we rename the character when it's REPLACE tag?
+ if(tag->hasName()) {
+ ch->set_name(tag->getName());
+ }
+ else if (ch->wantsInstanceName()) {
+ std::string instance_name = getNextUnnamedInstanceName();
+ ch->set_name(instance_name);
+ }
+ if (tag->hasRatio()) {
+ ch->set_ratio(tag->getRatio());
+ }
+ if (tag->hasCxform()) {
+ ch->set_cxform(tag->getCxform());
+ }
+ if (tag->hasMatrix()) {
+ ch->setMatrix(tag->getMatrix(), true);
+ }
+
+ // use SWFMatrix from the old character if tag doesn't provide one.
+ dlist.replace_character(ch.get(), tag->getDepth(),
+ !tag->hasCxform(), !tag->hasMatrix());
}
void
=== modified file 'libcore/parser/SWFMovieDefinition.cpp'
--- a/libcore/parser/SWFMovieDefinition.cpp 2009-03-13 22:46:37 +0000
+++ b/libcore/parser/SWFMovieDefinition.cpp 2009-03-23 14:34:35 +0000
@@ -549,16 +549,16 @@
SWFStream &str = *_str;
- try {
-
- while (str.tell() < _swf_end_pos)
+ while (str.tell() < _swf_end_pos)
+ {
+ if (_loadingCanceled)
{
- if (_loadingCanceled)
- {
- log_debug("Loading thread cancelation requested, "
- "returning from read_all_swf");
- return;
- }
+ log_debug("Loading thread cancelation requested, "
+ "returning from read_all_swf");
+ return;
+ }
+
+ try {
SWF::TagType tag = str.open_tag();
@@ -620,21 +620,16 @@
);
}
- str.close_tag();
-
- setBytesLoaded(str.tell());
- }
-
- } catch (const ParserException& e) {
- // FIXME: we should be setting some variable
- // so that it is possible for clients
- // to check the parser status
- // Also, we should probably call _loader.unlock()
- // and make sure any wait_for_frame call is
- // released (condition set and false result)
- log_error(_("Parsing exception: %s"), e.what());
-
- }
+ }
+ catch (const ParserException& e) {
+ // Log and continue parsing...
+ log_error(_("Parsing exception: %s"), e.what());
+ }
+
+ str.close_tag();
+
+ setBytesLoaded(str.tell());
+ }
// Make sure we won't leave any pending writers
// on any eventual fd-based IOChannel.
=== modified file 'libcore/parser/sprite_definition.cpp'
--- a/libcore/parser/sprite_definition.cpp 2009-03-13 22:46:37 +0000
+++ b/libcore/parser/sprite_definition.cpp 2009-03-23 12:51:41 +0000
@@ -76,31 +76,30 @@
m_loading_frame = 0;
- while ( in.tell() < tag_end )
- {
+ while (in.tell() < tag_end) {
+
SWF::TagType tag = in.open_tag();
- SWF::TagLoadersTable::loader_function lf = NULL;
-
- if (tag == SWF::END)
- {
- if (in.tell() != tag_end)
- {
- IF_VERBOSE_MALFORMED_SWF(
- // Safety break, so we don't read past
- // the end of the movie.
- log_swferror(_("Hit end tag, "
- "before the advertised DEFINESPRITE
end; "
- "stopping for safety."));
- )
+ SWF::TagLoadersTable::loader_function lf = 0;
+
+ if (tag == SWF::END) {
+
+ if (in.tell() != tag_end) {
+ IF_VERBOSE_MALFORMED_SWF(
+ // Safety break, so we don't read past
+ // the end of the movie.
+ log_swferror(_("Hit end tag, "
+ "before the advertised DEFINESPRITE end; "
+ "stopping for safety."));
+ );
in.close_tag();
- break;
+ break;
}
}
- else if (tag == SWF::SHOWFRAME)
- {
+
+ else if (tag == SWF::SHOWFRAME) {
// show frame tag -- advance to the next frame.
- ++m_loading_frame;
+ ++m_loading_frame;
IF_VERBOSE_PARSE (
log_parse(_(" show_frame %d/%d"
@@ -109,32 +108,29 @@
m_frame_count);
);
- if ( m_loading_frame == m_frame_count )
- {
+ if (m_loading_frame == m_frame_count) {
+
// better break then sorry
-
in.close_tag();
- if ( in.open_tag() != SWF::END )
+ if (in.open_tag() != SWF::END)
{
IF_VERBOSE_MALFORMED_SWF(
- log_swferror(_("last SHOWFRAME of a "
- "DEFINESPRITE tag "
- "isn't followed by an END."
- " Stopping for safety."));
- );
+ log_swferror(_("last SHOWFRAME of a "
+ "DEFINESPRITE tag "
+ "isn't followed by an END."
+ " Stopping for safety."));
+ );
in.close_tag();
return;
}
}
}
- else if (_tag_loaders.get(tag, &lf))
- {
+ else if (_tag_loaders.get(tag, &lf)) {
// call the tag loader. The tag loader should add
// characters or tags to the movie data structure.
(*lf)(in, tag, *this, runInfo);
}
- else
- {
+ else {
// no tag loader for this tag type.
// FIXME, should this be a log_swferror instead?
log_error(_("*** no tag loader for type %d (sprite)"),
@@ -144,23 +140,22 @@
in.close_tag();
}
- if ( m_frame_count > m_loading_frame )
- {
- IF_VERBOSE_MALFORMED_SWF(
- log_swferror(_("%d frames advertised in header, but only %d
SHOWFRAME tags "
- "found in define sprite."), m_frame_count,
m_loading_frame );
- );
-
- // this should be safe
- m_loading_frame = m_frame_count;
- }
-
- IF_VERBOSE_PARSE (
- log_parse(_(" -- sprite END --"));
- );
+ if (m_frame_count > m_loading_frame) {
+ IF_VERBOSE_MALFORMED_SWF(
+ log_swferror(_("%d frames advertised in header, but "
+ "only %d SHOWFRAME tags found in define "
+ "sprite."), m_frame_count, m_loading_frame );
+ );
+
+ // this should be safe
+ m_loading_frame = m_frame_count;
+ }
+
+ IF_VERBOSE_PARSE(
+ log_parse(_(" -- sprite END --"));
+ );
}
-/*virtual*/
void
sprite_definition::add_frame_name(const std::string& name)
{
@@ -171,7 +166,8 @@
}
bool
-sprite_definition::get_labeled_frame(const std::string& label, size_t&
frame_number)
+sprite_definition::get_labeled_frame(const std::string& label,
+ size_t& frame_number)
{
NamedFrameMap::const_iterator it = _namedFrames.find(label);
if ( it == _namedFrames.end() ) return false;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] /srv/bzr/gnash/trunk r10736: Continue to parse the next tag after a parsing exception.,
Benjamin Wolsey <=