Title: [132681] trunk/Source/WebCore
Revision
132681
Author
[email protected]
Date
2012-10-26 11:51:21 -0700 (Fri, 26 Oct 2012)

Log Message

Remove the circular reference between TextTrack and TextTrackCue
https://bugs.webkit.org/show_bug.cgi?id=100300

Patch by Aaron Colwell <[email protected]> on 2012-10-26
Reviewed by Eric Carlson.

Changed TextTrackCue.m_track to a normal pointer to break the circular
reference that was keeping both objects from ever getting deleted.

No new tests. This simply fixes a memory leak.

* html/track/TextTrack.cpp:
(WebCore::TextTrack::~TextTrack):
* html/track/TextTrackCue.cpp:
(WebCore::TextTrackCue::TextTrackCue):
(WebCore::TextTrackCue::~TextTrackCue):
(WebCore::TextTrackCue::track):
(WebCore::TextTrackCue::setTrack):
* html/track/TextTrackCue.h:
(TextTrackCue):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (132680 => 132681)


--- trunk/Source/WebCore/ChangeLog	2012-10-26 18:47:29 UTC (rev 132680)
+++ trunk/Source/WebCore/ChangeLog	2012-10-26 18:51:21 UTC (rev 132681)
@@ -1,3 +1,25 @@
+2012-10-26  Aaron Colwell  <[email protected]>
+
+        Remove the circular reference between TextTrack and TextTrackCue
+        https://bugs.webkit.org/show_bug.cgi?id=100300
+
+        Reviewed by Eric Carlson.
+
+        Changed TextTrackCue.m_track to a normal pointer to break the circular
+        reference that was keeping both objects from ever getting deleted.
+
+        No new tests. This simply fixes a memory leak.
+
+        * html/track/TextTrack.cpp:
+        (WebCore::TextTrack::~TextTrack):
+        * html/track/TextTrackCue.cpp:
+        (WebCore::TextTrackCue::TextTrackCue):
+        (WebCore::TextTrackCue::~TextTrackCue):
+        (WebCore::TextTrackCue::track):
+        (WebCore::TextTrackCue::setTrack):
+        * html/track/TextTrackCue.h:
+        (TextTrackCue):
+
 2012-10-26  Vsevolod Vlasov  <[email protected]>
 
         Web Inspector: Breakpoints are not managed correctly when editing uiSourceCode that was bound to ScriptFile after _javascript_SourceFrame creation.

Modified: trunk/Source/WebCore/html/track/TextTrack.cpp (132680 => 132681)


--- trunk/Source/WebCore/html/track/TextTrack.cpp	2012-10-26 18:47:29 UTC (rev 132680)
+++ trunk/Source/WebCore/html/track/TextTrack.cpp	2012-10-26 18:51:21 UTC (rev 132681)
@@ -112,8 +112,13 @@
 
 TextTrack::~TextTrack()
 {
-    if (m_client && m_cues)
-        m_client->textTrackRemoveCues(this, m_cues.get());
+    if (m_cues) {
+        if (m_client)
+            m_client->textTrackRemoveCues(this, m_cues.get());
+
+        for (size_t i = 0; i < m_cues->length(); ++i)
+            m_cues->item(i)->setTrack(0);
+    }
     clearClient();
 }
 

Modified: trunk/Source/WebCore/html/track/TextTrackCue.cpp (132680 => 132681)


--- trunk/Source/WebCore/html/track/TextTrackCue.cpp	2012-10-26 18:47:29 UTC (rev 132680)
+++ trunk/Source/WebCore/html/track/TextTrackCue.cpp	2012-10-26 18:51:21 UTC (rev 132681)
@@ -210,6 +210,7 @@
     , m_writingDirection(Horizontal)
     , m_cueAlignment(Middle)
     , m_documentFragment(0)
+    , m_track(0)
     , m_scriptExecutionContext(context)
     , m_isActive(false)
     , m_pauseOnExit(false)
@@ -252,10 +253,10 @@
 
 TextTrack* TextTrackCue::track() const
 {
-    return m_track.get();
+    return m_track;
 }
 
-void TextTrackCue::setTrack(PassRefPtr<TextTrack>track)
+void TextTrackCue::setTrack(TextTrack* track)
 {
     m_track = track;
 }

Modified: trunk/Source/WebCore/html/track/TextTrackCue.h (132680 => 132681)


--- trunk/Source/WebCore/html/track/TextTrackCue.h	2012-10-26 18:47:29 UTC (rev 132680)
+++ trunk/Source/WebCore/html/track/TextTrackCue.h	2012-10-26 18:51:21 UTC (rev 132681)
@@ -85,7 +85,7 @@
     static const AtomicString& futureNodesShadowPseudoId();
 
     TextTrack* track() const;
-    void setTrack(PassRefPtr<TextTrack>);
+    void setTrack(TextTrack*);
 
     const String& id() const { return m_id; }
     void setId(const String&);
@@ -197,7 +197,7 @@
     Alignment m_cueAlignment;
 
     RefPtr<DocumentFragment> m_documentFragment;
-    RefPtr<TextTrack> m_track;
+    TextTrack* m_track;
 
     EventTargetData m_eventTargetData;
     ScriptExecutionContext* m_scriptExecutionContext;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to