From 754cfc78b3550ccb0e65ed80c4a32c7ff2d5b8a4 Mon Sep 17 00:00:00 2001 From: Teo Mrnjavac Date: Wed, 27 Jul 2016 17:22:56 +0200 Subject: [PATCH] Make che color cache indexed by UUID instead of by path. --- src/modules/partition/core/ColorUtils.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/modules/partition/core/ColorUtils.cpp b/src/modules/partition/core/ColorUtils.cpp index 1fcf9e70f..eb3150ab7 100644 --- a/src/modules/partition/core/ColorUtils.cpp +++ b/src/modules/partition/core/ColorUtils.cpp @@ -84,8 +84,11 @@ colorForPartition( Partition* partition ) return FREE_SPACE_COLOR; if ( partition->roles().has( PartitionRole::Extended ) ) return EXTENDED_COLOR; - if ( s_partitionColorsCache.contains( partition->partitionPath() ) ) - return s_partitionColorsCache[ partition->partitionPath() ]; + + if ( partition->fileSystem().supportGetUUID() != FileSystem::cmdSupportNone && + !partition->fileSystem().uuid().isEmpty() && + s_partitionColorsCache.contains( partition->fileSystem().uuid() ) ) + return s_partitionColorsCache[ partition->fileSystem().uuid() ]; // No partition-specific color needed, pick one from our list, but skip // free space: we don't want a partition to change colors if space before @@ -114,8 +117,10 @@ colorForPartition( Partition* partition ) if ( KPMHelpers::isPartitionNew( partition ) ) return NEW_PARTITION_COLORS[ newColorIdx % NUM_NEW_PARTITION_COLORS ]; - s_partitionColorsCache.insert( partition->partitionPath(), - PARTITION_COLORS[ colorIdx % NUM_PARTITION_COLORS ] ); + if ( partition->fileSystem().supportGetUUID() != FileSystem::cmdSupportNone && + !partition->fileSystem().uuid().isEmpty() ) + s_partitionColorsCache.insert( partition->fileSystem().uuid(), + PARTITION_COLORS[ colorIdx % NUM_PARTITION_COLORS ] ); return PARTITION_COLORS[ colorIdx % NUM_PARTITION_COLORS ]; }