[Slim-Checkins] r9175 - in /trunk/server/Slim: Buttons/Common.pm Player/Client.pm

adrian at svn.slimdevices.com adrian at svn.slimdevices.com
Sat Aug 26 03:24:49 PDT 2006


Author: adrian
Date: Sat Aug 26 03:24:46 2006
New Revision: 9175

URL: http://svn.slimdevices.com?rev=9175&view=rev
Log:
Bug: N/A
Description: Moser convinced me modeParams are not persitent if the
mode sets them correctly.  Remove modeVariable alternative and go back
to using modeParams for screen2 state.

Modified:
    trunk/server/Slim/Buttons/Common.pm
    trunk/server/Slim/Player/Client.pm

Modified: trunk/server/Slim/Buttons/Common.pm
URL: http://svn.slimdevices.com/trunk/server/Slim/Buttons/Common.pm?rev=9175&r1=9174&r2=9175&view=diff
==============================================================================
--- trunk/server/Slim/Buttons/Common.pm (original)
+++ trunk/server/Slim/Buttons/Common.pm Sat Aug 26 03:24:46 2006
@@ -1560,7 +1560,7 @@
 
 	$::d_ui && msg("pushing button mode: $setmode\n");
 
-	my $oldscreen2 = $client->modeVariable('screen2');
+	my $oldscreen2 = $client->modeParam('screen2active');
 
 	my $oldmode = mode($client);
 
@@ -1587,8 +1587,6 @@
 
 	push @{$client->modeParameterStack}, $paramHashRef;
 
-	push @{$client->modeVariableStack}, {};
-
 	my $newModeFunction = $modes{$setmode};
 
 	if (!$newModeFunction || ref($newModeFunction) ne "CODE") {
@@ -1611,8 +1609,8 @@
 			$screen2 = $oldscreen2;
 		}
 
-		# set mode variable screen2 so we can modify it later
-		$client->modeVariable('screen2', $screen2);
+		# set active param so we can modify it later
+		$client->modeParam('screen2active', $screen2);
 	}
 
 	# some modes require periodic updates
@@ -1642,7 +1640,7 @@
 		return undef;
 	}
 
-	my $oldscreen2 = $client->modeVariable('screen2');
+	my $oldscreen2 = $client->modeParam('screen2active');
 
 	my $oldMode = mode($client);
 
@@ -1657,7 +1655,6 @@
 	
 	pop @{$client->modeStack};
 	pop @{$client->modeParameterStack};
-	pop @{$client->modeVariableStack};
 	$scrollClientHash->{$client}{scrollParams} = pop @{$scrollClientHash->{$client}{scrollParamsStack}};
 	
 	my $newmode = mode($client);
@@ -1672,18 +1669,18 @@
 
 		my $suppressScreen2Update = shift;
 
-		my $screen2 = $client->modeVariable('screen2');
+		my $screen2 = $client->modeParam('screen2active');
 
 		if ($client->display->showExtendedText()) {
 
-			$client->modeVariable('screen2', 'periodic') unless $screen2;
+			$client->modeParam('screen2active', 'periodic') unless $screen2;
 
 		} elsif ($screen2 && $screen2 eq 'periodic') {
 
-			$client->modeVariable('screen2', undef);
-		}
-
-		if (!$suppressScreen2Update && $oldscreen2 && !$client->modeVariable('screen2')) {
+			$client->modeParam('screen2active', undef);
+		}
+
+		if (!$suppressScreen2Update && $oldscreen2 && !$client->modeParam('screen2active')) {
 
 			$client->update( { 'screen2' => {} } );
 		}
@@ -1726,7 +1723,7 @@
 
 	} else {
 
-		my $oldscreen2 = $client->modeVariable('screen2');
+		my $oldscreen2 = $client->modeParam('screen2active');
 
 		pushMode($client, $setmode, $paramHashRef);
 
@@ -1751,7 +1748,7 @@
 
 	} else {
 
-		my $oldscreen2 = $client->modeVariable('screen2');
+		my $oldscreen2 = $client->modeParam('screen2active');
 
 		Slim::Buttons::Common::popMode($client, 1);
 
@@ -1767,7 +1764,7 @@
 
 	my $newlines = $display->curLines();
 
-	my $newscreen2 = $client->modeVariable('screen2');
+	my $newscreen2 = $client->modeParam('screen2active');
 
 	if ($newscreen2 && $newscreen2 eq 'periodic' && $oldscreen2 ne 'periodic') {
 		my $linesfunc = $client->lines2periodic();
@@ -1783,17 +1780,17 @@
 sub updateScreen2Mode {
 	my $client = shift || return;
 
-	my $screen2 = $client->modeVariable('screen2');
+	my $screen2 = $client->modeParam('screen2active');
 
 	if ($client->display->showExtendedText()) {
 		if (!$screen2) {
-			$client->modeVariable('screen2', 'periodic');
+			$client->modeParam('screen2active', 'periodic');
 			startPeriodicUpdates($client);
 		}
 	} else {
 		if ($screen2) {
 			if ($screen2 eq 'periodic') {
-				$client->modeVariable('screen2', undef);
+				$client->modeParam('screen2active', undef);
 			}
 			$client->update( { 'screen2' => {} } );
 		}
@@ -1805,7 +1802,7 @@
 
 	return undef unless $client->display->hasScreen2();
 
-	my $screen2 = $client->modeVariable('screen2');
+	my $screen2 = $client->modeParam('screen2active');
 
 	if ($screen2 && $screen2 eq 'periodic') {
 		return 1;
@@ -1831,7 +1828,7 @@
 	my $interval  = $client->param('modeUpdateInterval');
 	my $interval2 = undef;
 
-	if ($client->modeVariable('screen2') && $client->modeVariable('screen2') eq 'periodic') {
+	if ($client->modeParam('screen2active') && $client->modeParam('screen2active') eq 'periodic') {
 
 		$interval2 = 1;
 	}
@@ -1862,7 +1859,7 @@
 	my $update  = $client->param('modeUpdateInterval');
 	my $update2 = undef;
 
-	if ($client->modeVariable('screen2') && $client->modeVariable('screen2') eq 'periodic') {
+	if ($client->modeParam('screen2active') && $client->modeParam('screen2active') eq 'periodic') {
 
 		$update2 = 1;
 	}

Modified: trunk/server/Slim/Player/Client.pm
URL: http://svn.slimdevices.com/trunk/server/Slim/Player/Client.pm?rev=9175&r1=9174&r2=9175&view=diff
==============================================================================
--- trunk/server/Slim/Player/Client.pm (original)
+++ trunk/server/Slim/Player/Client.pm Sat Aug 26 03:24:46 2006
@@ -163,7 +163,7 @@
 	$client->[101] = undef; # lines2periodic
 	$client->[102] = 0; # periodicUpdateTime
 	$client->[103] = undef; # musicInfoTextCache
-	$client->[104] = [ {} ];# modeVariableStack
+	$client->[104] = undef; # unused
 	# 105 is scroll state
 	$client->[106] = undef; # knobPos
 	$client->[107] = undef; # knobTime
@@ -757,22 +757,10 @@
 }
 
 # this is a replacement for param that allows you to pass undef to clear a parameter
-# NB mode parameters may persist between instances of a mode.  They should therefore not be used
-# for state which should not persist between instances of a mode - use modeVariable instead
 sub modeParam {
 	my $client = shift;
 	my $name   = shift;
 	my $mode   = $client->modeParameterStack(-1) || return undef;
-
-	@_ ? ($mode->{$name} = shift) : $mode->{$name};
-}
-
-# Mode variables are accessed by this function.  Mode variables are used for state which should not
-# persist between instances of a mode
-sub modeVariable {
-	my $client = shift;
-	my $name   = shift;
-	my $mode   = $client->modeVariableStack(-1) || return undef;
 
 	@_ ? ($mode->{$name} = shift) : $mode->{$name};
 }
@@ -1595,13 +1583,6 @@
 	@_ ? ($r->[103] = shift) : $r->[103];
 }
 
-sub modeVariableStack {
-	my $r = shift;
-	my $i;
-	@_ ? ($i = shift) : return $r->[104];
-	@_ ? ($r->[104]->[$i] = shift) : $r->[104]->[$i];
-}
-
 sub knobPos {
 	my $r = shift;
 	@_ ? ($r->[106] = shift) : $r->[106];



More information about the checkins mailing list