Ender66 / tunesremote-plus

Automatically exported from code.google.com/p/tunesremote-plus
0 stars 0 forks source link

2.5.2: Stack Overflow Error #106

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
java.lang.StackOverflowError
at java.lang.Thread.sleep(Thread.java:1229)
at java.lang.Thread.sleep(Thread.java:1211)
at org.tunesremote.PlaylistsFragment.onServiceConnected() (Unknown Source)

Looks like there is a recursion error situation in all 3 fragments where it 
sleeps and then calls itself again.  This code definitely is not safe as it 
will continue to loop until it Stack Overflow happens.  We need to find a a 
better way to accomplish this or figure out why the Activity is NULL ever at 
all. 

@Override
   public void onServiceConnected() {
      host = (LibraryBrowseActivity) getActivity();
      if (host != null) {
         if (adapter.results.isEmpty()) {
            host.library.readPlaylists(adapter);
         }
      } else {
         // Not quite ready, snooze for a bit
         try {
            Thread.sleep(500);
            onServiceConnected();
         } catch (InterruptedException e) {
            Log.e(TAG, "Waiting for Activity connection interrupted " + e);
         }
      }
   }

Original issue reported on code.google.com by mellowaredev on 15 Jul 2012 at 1:28

GoogleCodeExporter commented 9 years ago

Original comment by mellowaredev on 15 Jul 2012 at 6:32