[prev in list] [next in list] [prev in thread] [next in thread] 

List:       helix-player-dev
Subject:    [Player-dev] Resend-CR: [#8085] Fixing a series of bugs
From:       Kinson Liu <kliu () real ! com>
Date:       2008-09-24 0:45:28
Message-ID: 48D98DA8.8090306 () real ! com
[Download RAW message or body]

This is a MIME-formatted message.  If you see this text it means that your
E-mail software does not support MIME-formatted messages.

[Attachment #2 (multipart/alternative)]
This is a MIME-formatted message.  If you see this text it means that your
E-mail software does not support MIME-formatted messages.


Notice this is a bit different than the initial CR in that I fixed a 
glitch in my early solution.

Modified by: kliu@real.com
Date: 9/23/2008
Project: RealPlayer for MID
Bug Number: 8085
Bug URL: https://bugs.helixcommunity.org/show_bug.cgi?id=8085

Synopsis: Fixing a series of bugs accompanying cursor disappears after 
deleting a song when another song is playing back

Overview: This patch fixes couples issues.
1. The program uses the same variable pl.selected_index to denote two 
states: a) the audio playing back and b) the audio selected.  Because 
the two states are different things, such a mix-up causes the playback 
icon to be attached to the selected audio instead of the one playing 
back after deletion.  As the selected audio is already deleted, the 
playback icon is unseen.
2. Audios inside a playlist are structured like an arraylist and the 
audio playing back is referenced by its index in the arraylist.  When an 
audio is deleted, all audios after it move up by one slot.  However, the 
program does not update the playback audio index accordingly, leaving it 
pointing to the old slot.  The playback icon will not be attached to the 
correct audio for cases like that.
3. By nature, the player has to highlight the selected audio, but that 
is not true after an audio is deleted.  Because the variable 
pl.selected_index is also used to denote the playing back audio, what 
actually gets highlighted is the playing back one instead of the 
selected one.
4. The player does not highlight any audio after audio deletion under 
the Online Music mode when another audio under the All Songs mode is 
playing back.

The fixes are using different variables for the two states.  Since 
self.item_selected is already there for that purpose, we will keep using 
it.  Since the two states are separated, we can decrement 
pl.selected_index whenever an audio above the playback one is deleted as 
the solution for #2 without affecting other variables/aspects.  Then for 
#3, we can set the highlight according to self.item_selected instead of 
pl.selected_index, which remains as the index of the current playback 
audio.  Finally, the update_radio_list_status_pixmap function is 
modified such that set_cursor is still being executed even though 
self.cur_playlist != self.view_playlist because we have such a use 
case.  At the same time, the function index_of is added to playlist.py 
to smooth the execution of self.item_selected, and the function 
selected__set() and the try-except blocks insider on_del_song are 
refactored.

Files Added:
None

Files Modified:
player/mid/src/music_view.py
player/mid/src/playlist.py

Image Size and Heap Use impact (Client -Only):
None

Platforms and Profiles Affected:
Platform: linux-2.2-libc6-gcc32-i586
Profile: Helix-client-moblin

Distribution Libraries Affected:
None

Distribution library impact and planned action:
None

Platforms and Profiles Build Verified:
Platform: linux-2.2-libc6-gcc32-i586
Profile: Helix-client-moblin

Platforms and Profiles Functionality verified:
Platform: linux-2.2-libc6-gcc32-i586
Profile: Helix-client-moblin

Branch: hxclient_3_4_1_atlas_restricted
 
Copyright assignment: I am a RealNetworks employee or contractor
-- 
------------------------------------------------------------------------
*Kinson Liu* | Software Development Engineer | RealNetworks, Inc. | 
kliu@real.com | 206.892.6177

[Attachment #5 (text/html)]

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head>
<body bgcolor="#ffffff" text="#000000">
Notice this is a bit different than the initial CR in that I fixed a
glitch in my early solution.<br>
<br>
Modified by: <a class="moz-txt-link-abbreviated"
 href="mailto:kliu@real.com">kliu@real.com</a><br>
Date: 9/23/2008<br>
Project: RealPlayer for MID<br>
Bug Number: 8085<br>
Bug URL: <a class="moz-txt-link-freetext"
 href="https://bugs.helixcommunity.org/show_bug.cgi?id=8076&amp;link=0">https://bugs.helixcommunity.org/show_bug.cgi?id=8085</a><br>
 <br>
Synopsis: Fixing a series of bugs accompanying cursor disappears after
deleting a song when another
song is playing back<br>
<br>
Overview: This patch fixes couples issues.<br>
1. The program uses the same variable pl.selected_index to denote two
states: a) the audio playing back and b) the audio selected.&nbsp; Because
the two states are different things, such a mix-up causes the playback
icon to be attached to the selected audio instead of the one playing
back after deletion.&nbsp; As the selected audio is already deleted, the
playback icon is unseen.<br>
2. Audios inside a playlist are structured like an arraylist and the
audio playing back is referenced by its index in the arraylist.&nbsp; When
an audio is deleted, all audios after it move up by one slot.&nbsp; However,
the program does not update the playback audio index accordingly,
leaving it pointing to the old slot.&nbsp; The playback icon will not be
attached to the correct audio for cases like that.<br>
3. By nature, the player has to highlight the selected audio, but that
is not true after an audio is deleted.&nbsp; Because the variable
pl.selected_index is also used to denote the playing back audio, what
actually gets highlighted is the playing back one instead of the
selected one.<br>
4. The player does not highlight any audio after audio deletion under
the Online Music mode when another audio under the All Songs mode is
playing back.<br>
<br>
The fixes are using different variables for the two states.&nbsp; Since
self.item_selected is already there for that purpose, we will keep
using it.&nbsp; Since the two states are separated, we can decrement
pl.selected_index whenever an audio above the playback one is deleted
as the solution for #2 without affecting other variables/aspects.&nbsp; Then
for #3, we can set the highlight according to self.item_selected
instead of pl.selected_index, which remains as the index of the current
playback audio.&nbsp; Finally, the update_radio_list_status_pixmap function
is modified such that set_cursor is still being executed even though
self.cur_playlist != self.view_playlist because we have such a use
case.&nbsp; At the same time, the function index_of is added to playlist.py
to smooth the execution of self.item_selected, and the function
selected__set() and the try-except blocks insider on_del_song are
refactored.<br>
<br>
Files Added:<br>
None<br>
<br>
Files Modified:<br>
player/mid/src/music_view.py<br>
player/mid/src/playlist.py<br>
<br>
Image Size and Heap Use impact (Client -Only):<br>
None<br>
<br>
Platforms and Profiles Affected:<br>
Platform: linux-2.2-libc6-gcc32-i586<br>
Profile: Helix-client-moblin<br>
<br>
Distribution Libraries Affected:<br>
None<br>
<br>
Distribution library impact and planned action:<br>
None<br>
<br>
Platforms and Profiles Build Verified:<br>
Platform: linux-2.2-libc6-gcc32-i586<br>
Profile: Helix-client-moblin<br>
<br>
Platforms and Profiles Functionality verified:<br>
Platform: linux-2.2-libc6-gcc32-i586<br>
Profile: Helix-client-moblin <br>
<br>
Branch: hxclient_3_4_1_atlas_restricted<br>
&nbsp;<br>
Copyright assignment: I am a RealNetworks employee or contractor
<div class="moz-signature">-- <br>
<hr><b>Kinson Liu</b> | Software Development Engineer | RealNetworks,
Inc. | <a class="moz-txt-link-abbreviated" \
href="mailto:kliu@real.com">kliu@real.com</a> | 206.892.6177 </div>
</body>
</html>


["midplayer.diff" (text/plain)]

Index: music_view.py
===================================================================
RCS file: /cvsroot/player/mid/src/music_view.py,v
retrieving revision 1.7.4.2
diff -u -r1.7.4.2 music_view.py
--- music_view.py	5 Jun 2008 19:29:49 -0000	1.7.4.2
+++ music_view.py	23 Sep 2008 23:58:41 -0000
@@ -642,19 +642,28 @@
                     utils.error_msg(constant.MSG_DELETE_PLAYING_SONG_ERROR)
                     continue
                 if self.trash(song):
-                    pl.selected = ({'File': song})
-                    index = pl.selected_index  #store current index
-                    del pl[pl.selected_index]
-                    try:
-                        # want to select next avail item, but can't figure it out
-                        count = len(pl)
-                        if count == 0:
-                            return
-                        if index == count:
-                            index = index - 1
-                        pl.selected = ({'File': index})
-                    except PlayListError:
-                        pass
+                    index = pl.index_of(song)
+                    del pl[index]
+                    # if the audio deleted is prior to the playing audio,
+                    # move the playing index up by one (deleting an audio
+                    # pushes up the audios following by one slot in the playlist)
+                    if index < pl.selected_index:
+                        pl.selected_index = pl.selected_index - 1                        
+            #selecting other audio after deletion
+            try:
+                # if no more audio is available after deletion, select none
+                count = len(pl)
+                if count == 0:
+                    self.item_selected = -1
+                else:
+                    # if the audio deleted is the last in the playlist,
+                    # select the one above
+                    if index == count:
+                        index = index - 1
+
+                    self.item_selected = pl[index]['File']                
+            except PlayListError:
+                pass
             self.update_song_view(pl)
         else:
             for song in songs:
@@ -664,12 +673,28 @@
                 dlg_title = constant.MSG_CONFIRM_DELETE_TITLE
                 msg = _(constant.MSG_CONFIRM_DELETE_QUESTION) % (titles[songs.index(song)])
                 if gtk.RESPONSE_YES == utils.confirm_dialog(dlg_title, msg):
-                    pl.selected = ({'File': song})
-                    del pl[pl.selected_index]
-                    try:
-                        pl.selected = ({'File': cur_song})
-                    except PlayListError:
-                        pass
+                    index = pl.index_of(song)
+                    del pl[index]
+                    # if the audio deleted is prior to the playing audio,
+                    # move the playing index up by one (deleting an audio
+                    # pushes up the audios following by one slot in the playlist)
+                    if index < pl.selected_index:
+                        pl.selected_index = pl.selected_index - 1            
+            #selecting other audio after deletion
+            try:
+                # if no more audio is available after deletion, select none
+                count = len(pl)
+                if count == 0:
+                    self.item_selected = -1
+                else:
+                    # if the audio deleted is the last in the playlist,
+                    # select the one above
+                    if index == count:
+                        index = index - 1
+
+                    self.item_selected = pl[index]['File']       
+            except PlayListError:
+                pass
             self.update_radio_view(pl)    
 
     def on_edit_properities(self,widget):
@@ -923,20 +948,23 @@
             self._set_song_tree_row_status(self.song_model,
                                            gtk.STOCK_MEDIA_PLAY,
                                            cur_index)
-            self.song_tree.set_cursor(cur_index)
+        # if an audio is selected, highlight it
+        if self.item_selected != -1:
+            self.song_tree.set_cursor(self.view_playlist.index_of(self.item_selected))
 
     def update_radio_list_status_pixmap(self):
         # update the state pixmap
-        if self.cur_playlist != self.view_playlist:
-            return
-        for i in range(0, len(self.cur_playlist)):
-            self._set_song_tree_row_status(self.radio_model,  None, i)
-        cur_index = self.cur_playlist.selected_index
-        if cur_index >= 0:
-            self._set_song_tree_row_status(self.radio_model,
-                                           gtk.STOCK_MEDIA_PLAY,
-                                           cur_index)
-            self.radio_tree.set_cursor(cur_index)
+        if self.cur_playlist == self.view_playlist:
+            for i in range(0, len(self.cur_playlist)):
+                self._set_song_tree_row_status(self.radio_model,  None, i)
+            cur_index = self.cur_playlist.selected_index
+            if cur_index >= 0:
+                self._set_song_tree_row_status(self.radio_model,
+                                               gtk.STOCK_MEDIA_PLAY,
+                                               cur_index)
+        # if an audio is selected, highlight it
+        if self.item_selected != -1:
+            self.radio_tree.set_cursor(self.view_playlist.index_of(self.item_selected))
 
 class TextColumn(gtk.TreeViewColumn):
     def __init__(self, title, model_index, expand=False, editable=False,
Index: playlist.py
===================================================================
RCS file: /cvsroot/player/mid/src/playlist.py,v
retrieving revision 1.1.1.1.6.1
diff -u -r1.1.1.1.6.1 playlist.py
--- playlist.py	5 Jun 2008 19:29:49 -0000	1.1.1.1.6.1
+++ playlist.py	23 Sep 2008 23:58:41 -0000
@@ -217,7 +217,15 @@
     def __delitem__(self, index):
         BaseList.__delitem__(self, index)
         self.flush()
-        
+
+    def index_of(self, song):
+        i = 0
+        for e in self._list:
+            if e['File'] == song:
+                return i
+            i = i + 1
+        return -1
+
     def selected__get(self):
         if self._selected == -1:
             return None
@@ -225,14 +233,9 @@
             return self._list[self._selected]
 
     def selected__set(self, entry):
-        i = 0
-        for e in self._list:
-            if e['File'] == entry['File']:
-                self._selected = i
-                return
-            i = i + 1
-        self._selected = -1
-        raise PlayListError("%s not found in PlayList!" % (entry['File']))
+        self._selected = self.index_of(entry['File'])
+        if self._selected == -1:
+            raise PlayListError("%s not found in PlayList!" % (entry['File']))
 
     def directory__get(self):
         return self._directory


_______________________________________________
Player-dev mailing list
Player-dev@helixcommunity.org
http://lists.helixcommunity.org/mailman/listinfo/player-dev


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic