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

List:       haiku-commits
Subject:    [haiku-commits] haiku: hrev55756 - src/kits/tracker
From:       waddlesplash <waddlesplash () gmail ! com>
Date:       2021-12-31 17:41:31
Message-ID: 20211231174131.BC52846EBE () turing ! freelists ! org
[Download RAW message or body]

hrev55756 adds 1 changeset to branch 'master'
old head: a7c2c5f842c7772221a02855f114cc8d9addcfdf
new head: abef198c1ac3ade338630375b204dcaa453ca41d
overview: https://git.haiku-os.org/haiku/log/?qt=range&q=abef198c1ac3+%5Ea7c2c5f842c7

----------------------------------------------------------------------------

abef198c1ac3: Tracker: fix logic to use custom icons.
  
  Regression caused by refactorings in hrev55348.
  
  The logic for deciding when to use a built-in tracker icon was changed
  incorrectly to ignore attributes on directories, trash, etc (anything
  but executable applications). So the built-in icon was always used.
  
  This commit restores the previous logic.
  
  Shoud fix #17320 and #17371
  
  Change-Id: I51ba22db59a8b6dd2bd1121b56c753ed47224c57
  Reviewed-on: https://review.haiku-os.org/c/haiku/+/4841
  Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
  Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>

                             [ Adrien Destugues <pulkomandy@pulkomandy.tk> ]

----------------------------------------------------------------------------

Revision:    hrev55756
Commit:      abef198c1ac3ade338630375b204dcaa453ca41d
URL:         https://git.haiku-os.org/haiku/commit/?id=abef198c1ac3
Author:      Adrien Destugues <pulkomandy@pulkomandy.tk>
Date:        Fri Dec 31 12:40:02 2021 UTC
Committer:   waddlesplash <waddlesplash@gmail.com>
Commit-Date: Fri Dec 31 17:41:28 2021 UTC

Ticket:      https://dev.haiku-os.org/ticket/17320
Ticket:      https://dev.haiku-os.org/ticket/17371

----------------------------------------------------------------------------

2 files changed, 27 insertions(+), 15 deletions(-)
src/kits/tracker/Model.cpp | 40 ++++++++++++++++++++++++++--------------
src/kits/tracker/Model.h   |  2 +-

----------------------------------------------------------------------------

diff --git a/src/kits/tracker/Model.cpp b/src/kits/tracker/Model.cpp
index e9226e547d..e14034db43 100644
--- a/src/kits/tracker/Model.cpp
+++ b/src/kits/tracker/Model.cpp
@@ -599,7 +599,7 @@ Model::FinishSettingUpType()
 	// makes sense to look for a node-based icon. This serves as a hint to the
 	// icon cache, allowing it to not hit the disk again for models that do not
 	// have an icon defined by the node.
-	if (CheckNodeIconHint())
+	if (fBaseType != kLinkNode && !CheckAppIconHint())
 		fIconFrom = kUnknownNotFromNode;
 
 	if (fBaseType != kDirectoryNode
@@ -623,7 +623,7 @@ Model::FinishSettingUpType()
 				if (fPreferredAppName)
 					DeletePreferredAppVolumeNameLinkTo();
 
-				if (*type != '0')
+				if (*type != '\0')
 					fPreferredAppName = strdup(type);
 			}
 		}
@@ -720,11 +720,12 @@ Model::FinishSettingUpType()
 
 
 bool
-Model::CheckNodeIconHint() const
+Model::ShouldUseWellKnownIcon() const
 {
-	return (fBaseType == kDirectoryNode || fBaseType == kVolumeNode
-			|| fBaseType == kTrashNode || fBaseType == kDesktopNode)
-		|| (fBaseType == kExecutableNode && !CheckAppIconHint());
+	if (fBaseType == kDirectoryNode || fBaseType == kVolumeNode
+		|| fBaseType == kTrashNode || fBaseType == kDesktopNode)
+		return !CheckAppIconHint();
+	return false;
 }
 
 
@@ -732,13 +733,24 @@ bool
 Model::CheckAppIconHint() const
 {
 	attr_info info;
-	return fNode != NULL
-		// node is open, and it
-		&& (fNode->GetAttrInfo(kAttrIcon, &info) == B_OK
-		// has a vector icon, or
-			|| (fNode->GetAttrInfo(kAttrMiniIcon, &info) == B_OK
-				&& fNode->GetAttrInfo(kAttrLargeIcon, &info) == B_OK));
-			// has a mini _and_ large icon
+	if (fNode == NULL) {
+		// Node is not open.
+		return false;
+	}
+
+	if (fNode->GetAttrInfo(kAttrIcon, &info) == B_OK) {
+		// Node has a vector icon
+		return true;
+	}
+
+	if (fNode->GetAttrInfo(kAttrMiniIcon, &info) == B_OK
+		&& fNode->GetAttrInfo(kAttrLargeIcon, &info) == B_OK) {
+		// Node has a mini _and_ large icon
+		return true;
+	}
+
+	// If there isn't either of these, we can't use the icon attribute from the node.
+	return false;
 }
 
 
@@ -750,7 +762,7 @@ Model::ResetIconFrom()
 	if (InitCheck() != B_OK)
 		return;
 
-	if (CheckNodeIconHint()) {
+	if (ShouldUseWellKnownIcon()) {
 		BDirectory* directory = dynamic_cast<BDirectory*>(fNode);
 		if (WellKnowEntryList::Match(NodeRef()) > (directory_which)-1) {
 			fIconFrom = kTrackerSupplied;
diff --git a/src/kits/tracker/Model.h b/src/kits/tracker/Model.h
index fe0f48ca4a..838c41f9af 100644
--- a/src/kits/tracker/Model.h
+++ b/src/kits/tracker/Model.h
@@ -212,7 +212,7 @@ private:
 	status_t OpenNodeCommon(bool writable);
 	void SetupBaseType();
 	void FinishSettingUpType();
-	bool CheckNodeIconHint() const;
+	bool ShouldUseWellKnownIcon() const;
 	bool CheckAppIconHint() const;
 	void DeletePreferredAppVolumeNameLinkTo();
 	void CacheLocalizedName();


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

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