History log of /haiku/src/kits/tracker/IconCache.cpp
Revision Date Author Comments
# 3c416c7a 26-May-2023 Zardshard <0azrune6@zard.anonaddy.com>

Tracker: Remove failing ASSERT

This ASSERT causes a crash in the debug build of libtracker.so.

The crash occurs when two conditions are met:
1. There are files in the directory with icons specific to them. This
is the case with image files, whose icons preview what the contents
of the image are.
2. Tracker has not displayed those icons yet. This happens if the user
has not scrolled down far enough to see the icons.

One way to meet these conditions is to configure the build system to
compile a debug build of libtracker.so. Then compile icon-o-matic.
Then run icon-o-matic with the debug build of libtracker.so
LD_PRELOAD'ed.

With that, press File->Open and navigate to
/system/documentation/BeBook/images/admonitions. While in the images
folder, do not scroll up or down to view the icons of the images in the
folder. They should remain unrendered. It should crash as soon as
Tracker enters the admonitions folder.

The crash occurs because NodeIconCache::Deleting is called without a
corresponding call to NodeIconCache::AddItem. Tracker calls
NodeIconCache::AddItem whenever it renders an icon to cache the result.
Tracker, however, is lazy, and only renders the icon when it comes into
view. When navigating out of the directory, Tracker has to call
Deleting for every file in the directory since it doesn't keep track of
which icons it rendered and which icons it didn't. Thus, AddItem has
been called for some of the files, but Deleting has been called for all
of them, causing the assert to fail and the program to crash.

This commit fixes the problem by not requiring a call to AddItem for
each call to Deleting.

Change-Id: I1038ce70ca345c44812becee7f3752567e5b562a
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6474
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# c907db6c 27-Sep-2022 Oscar Lesta <oscar.lesta@gmail.com>

Tracker: fix build with DEBUG=1

Change-Id: Ieaaf23b0780f50837153634ad3e82eda6e5978f8
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5700
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# 0c973c94 26-Aug-2022 Augustin Cavalier <waddlesplash@gmail.com>

Tracker: Refactor IconCache size handling and usages.

* Instead of taking an icon_size, which we were having to cast
random integers to anyway, just take a BSize and convert internally
as needed. This simplifies a lot of usages of IconCache methods.

* Compute what B_MINI_ICON size will be at startup. This way,
we do not wind up caching "mini" icons in the fLarge*Icon variables
under HiDPI.

This does have a downside that if anything actually
does try to fetch "true mini" (16x16) icons when the real
ComposeIconSize(B_MINI_ICON) is larger than that, it will wind up
(confusingly) in fLarge*Icon, but that should not cause problems
and after this commit should not happen at all, anyway.

* Make mini-icon-mode use ComposeSize instead of the hardcoded 16x16,
and adjust metrics computations around it.

* Fetch larger icons in MountMenu logic. Also use BString::SetToFormat.

* Remove an unused, deprecated method from BPoseView.

* Rename variables in thumbnail generation code to match new behavior.


# a173592b 26-Apr-2022 Augustin Cavalier <waddlesplash@gmail.com>

Tracker: Fix memory leak in IconCache::SetIcon.

How often this would have occurred before thumbnail support I'm not sure,
but at least now that we have thumbnails, the icons are changed out
with not insignificant frequency, especially on read-only filesystems.


# 5192c3bf 25-Apr-2022 Augustin Cavalier <waddlesplash@gmail.com>

Tracker: Move thumbnail-manipulation code to its own file.

Preparatory work for refactoring thumbnail generation to not use
so many resources (threads, ports, etc.)


# 7f819534 05-Aug-2021 John Scipione <jscipione@gmail.com>

Tracker: Add thumbnail support

Define thumbnail attributes in Attributes.h:
Media:Thumbnail to store the thumbnail,
Media:Thumbnail:CreationTime to see if thumbs need to be regenerated.

Store 128x128 thumbnail in attribute, for icon sizes smaller than
128x128 down-scale the 128x128 thumbnail. Use B_FILTER_BITMAP_BILINEAR
to down-scale the image using the bilinear scaling algorithm which
creates nicer looking thumbnails than the default scaling algorithm.

Store thumbnails as WebP images which compress smaller than PNGs and
fit in the inode better at 128x128.

Check the file's modification time in GetFileIconFromAttr() and compare
it to the thumbnail creation time. If the file has not been modified
since the last time we generated thumbnails return the thumbnail from
the attribute, otherwise fetch a new thumbnail with GetThumbnailIcon().

Add "Generate image thumbnails" Tracker setting. Default is turned off
for now. To generate image thumbnails you must first turn this setting
on in Tracker Windows preferences.

Spawn a get_thumbnail() thread to generate thumbnails and retrieve them
later on from the window thread to fill out into the icon. This should
improve responsiveness of generating thumbnails from a folder with a
lot of images. The generator thread will write the thumbnail data to an
attribute if on writable BFS volume.

If not on writable BFS volume, the generator thread will send the data
back to the original thread through a port by calling write_port().

When the thread is finished creating the thumbnail it sends a message
back to the Tracker application thread to update the pose which
instructs the window thread to look for an thumbnail. It either finds a
thumbnail in an attribute, or picks up the thumbnail data that has been
sent through write_port() using read_port().

This works on both read-write and read-only BFS volumes but it still
depends on the presence of a BEOS:TYPE parameter to have been written
to the volume before it became read-only. Thumbnail generation does not
work on other read-only volumes for example an ISO-9660 CD, but it does
work on read-only BFS volumes for example the BeOS R5 CD.

Move BPrivate::CheckNodeIconHintPrivate() from BNodeInfo to Tracker
Model CheckNodeIconHint(). Create Model::CheckAppIconHint() and look
for a vector icon or mini and large icon in that method. Check that
the base type is directory, volume, trash, desktop, or if executable
call CheckAppIconHint().

Add 1 to temp_name to fix the following warning:
src/kits/tracker/FSUtils.cpp:2437:12: note: 'snprintf' output 3 or more
bytes (assuming 267) into a destination of size 266

Rename temp_name to tempName following our style guidelines. Use
strlcpy() and strlcat() instead of strcpy() to safely copy the string.
This fixes thumbnail generation on 64-bit Haiku.

Change-Id: I7f927a5a1f8cf65e4b1aa1e0eb55bbfae87fd969
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3163
Reviewed-by: John Scipione <jscipione@gmail.com>
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>


# 451cf86f 11-May-2020 X512 <danger_mail@list.ru>

Tracker: fix debug build

Change-Id: I8a31802366b3dcbadc9ce1ba903161fa3fcad60d
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2679
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# 8eaf4427 11-Mar-2020 Augustin Cavalier <waddlesplash@gmail.com>

Tracker: Refactor IconCache to use BOpenHashTable.

This removes the last usage of the old OpenTracker OpenHashTable,
and so it can now be removed.

Change-Id: I7a7bceef1d3fc74c7fdfa7b079e53576452703dc
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2339
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Reviewed-by: John Scipione <jscipione@gmail.com>
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>


# ab56137e 26-Aug-2019 Adrien Destugues <pulkomandy@pulkomandy.tk>

IconCache: remove incorrect ASSERT()

The code does just fine both if entry is NULL and if it doesn't have an
icon. However, if entry is NULL, this assert calls a method on it, which
is a bad idea.

Change-Id: I80b314db373970d99eb008aeaec6254d14c39ca7
Reviewed-on: https://review.haiku-os.org/c/haiku/+/1749
Reviewed-by: Stephan Aßmus <superstippi@gmx.de>


# e3af9ff0 18-Nov-2018 Murai Takashi <tmurai01@gmail.com>

kits/tracker: Fix PVS 923

Fix 'entry' is assigned values twice successively.

Change-Id: I86456bf156eb48f3966439a854256e27ee87caaf
Reviewed-on: https://review.haiku-os.org/765
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>


# d0a9f680 04-Apr-2015 Michael Lotz <mmlr@mlotz.ch>

Tracker: Fix use-after-free on destruction of the icon caches.

The hash table member still uses the element array memeber to clear
itself on destruction. We must therefore ensure that the element array
isn't destroyed before the hash table. Since the destruction order of
memebers is the reverse order of their declaration, reordering them
is enough.


# c6433b0b 17-Jul-2014 John Scipione <jscipione@gmail.com>

Tracker: A few more style fixes to IconCache

* Hilight => Highlight


# ae7d51b2 02-Jul-2014 John Scipione <jscipione@gmail.com>

Tracker: Style fixes to IconCache and Utilities


# d73129ff 21-Jun-2014 John Scipione <jscipione@gmail.com>

Tracker: style fixes to IconCache


# f2ed4761 20-Jun-2014 John Scipione <jscipione@gmail.com>

Tracker: style fixes to IconCache


# 38fa81bf 03-Oct-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

Remove B_COMMON*_DIRECTORY and kCommon*Directory constants

* This does intentionally break source compatibility, so that a review
of concerned code is forced.
* Binary compatibility should be maintained in most cases. The values
of the constants for the writable directories are now used for the
writable system directories. The values for the non-writable
directories are mapped to "/boot/system/data/empty/...", an empty or
non-existent directory, so that they will simply be skipped in search
paths. Only code that explicitly expects to find something in a
B_COMMON_* directory, will fail.


# db416834 02-Jan-2013 Matt Madia <mattmadia@gmail.com>

Automatic whitespace cleanup. No functional change.


# a51764c5 27-Jul-2012 John Scipione <jscipione@gmail.com>

WIP: Yet more style fixes, mostly 80 char violations.


# b05aa8b5 27-Jul-2012 John Scipione <jscipione@gmail.com>

Style changes in Tracker, no functional change.

Manual whitespace cleanup
Change instances of const char * to const char*
Convert /* */ C style comments to // C++ style comments


# aa56e459 20-Jun-2011 Jérôme Duval <korli@users.berlios.de>

revert r42251. Cast the enum to uint32 before use in switchs to please GCC 4.5.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42266 a95241bf-73f2-0310-859d-f6bbb57e9c96


# aa61ee48 17-Jan-2010 Rene Gollent <anevilyak@gmail.com>

Cleaned up legacy icon mappings and add some missing resource definitions to
TrackerIcons.h. Also removed the setup for the folder icon mimetype in
TrackerInitialState, as it was using a non-existent resource ID to do so with.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35118 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 5422febd 14-Jul-2009 Stephan Aßmus <superstippi@gmx.de>

Fixed a few coding style violations and GCC4 warnings.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31555 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 4fba3522 11-Apr-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* Removed src/kits/tracker/OpenHashTable.h. The shared version in
headers/private/shared is newer, though with small interface changes.
* Removed the unnecessary Debug.h include in
headers/private/shared/ObjectList.h.
* Adjusted sources using these headers, mostly by adding missing includes.
* Lots of automatic whitespace cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30123 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 67fb7cd0 28-Mar-2007 Axel Dörfler <axeld@pinc-software.de>

Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20443 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a803529b 19-Jan-2007 Axel Dörfler <axeld@pinc-software.de>

As Marcus noticed, some icons were gone after my last change; in fact no icons
were shown for all files without an own icon, and without one from its MIME type.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19866 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8cddf191 16-Jan-2007 Axel Dörfler <axeld@pinc-software.de>

Tracker now prefers an icon coming directly from the MIME type over one specified
by the application - as FileTypes already did.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19829 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 358b3c8e 14-Sep-2006 Stephan Aßmus <superstippi@gmx.de>

* don't mess so much with the drawing and blending mode when
drawing icons, most importantly, don't switch from compositing
to pixel alpha, this fixes the drag bitmap generation, now
it looks beautiful


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18846 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7fb6186f 29-Aug-2006 Stephan Aßmus <superstippi@gmx.de>

* integration of vector icons with the registrar and the mime data base
* additional versions of SetIcon[ForType] and GetIcon[ForType] in BMimeType
and BAppFileInfo, which handle flat vector icon data
* changes in Tracker to support scalable icons (currently broken for
non-vector icons and needs cleanup) and drawing icons correctly with alpha
channel (large parts of this work done by Michael Lotz)

If someone feels like looking over the changes, that would be much
appreciated! :-)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18699 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 9ecf9d1c 26-Aug-2006 Ingo Weinhold <ingo_weinhold@gmx.de>

Merge from layout management branch.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18649 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e68b7626 11-Dec-2005 Axel Dörfler <axeld@pinc-software.de>

More GCC 4 fixes by Ingo Weinhold - appeared because of the recent removal
of new/typeinfo/exception from our headers.
Rearranged the IconCache node_ref hash computation to be padding-resistant
(at least on PPC, node_ref is 16 bytes long, not 12 as it is with x86 and GCC 2).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15498 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 59e89c60 26-Nov-2005 Axel Dörfler <axeld@pinc-software.de>

Fixed a locking bug in the icon cache.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15172 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 02be5353 22-May-2005 Axel Dörfler <axeld@pinc-software.de>

Added libtracker.so to the repository and the build.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12772 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d0a9f6803b662ad1c9b20bf5dff1d461b1d71548 04-Apr-2015 Michael Lotz <mmlr@mlotz.ch>

Tracker: Fix use-after-free on destruction of the icon caches.

The hash table member still uses the element array memeber to clear
itself on destruction. We must therefore ensure that the element array
isn't destroyed before the hash table. Since the destruction order of
memebers is the reverse order of their declaration, reordering them
is enough.


# c6433b0b3cf69e9481b4bc46fec636879145d116 17-Jul-2014 John Scipione <jscipione@gmail.com>

Tracker: A few more style fixes to IconCache

* Hilight => Highlight


# ae7d51b28a8826a1f8330f28dead633d98cc42bd 02-Jul-2014 John Scipione <jscipione@gmail.com>

Tracker: Style fixes to IconCache and Utilities


# d73129ff46f7bded9c440b6a486d9d9bb19d712e 21-Jun-2014 John Scipione <jscipione@gmail.com>

Tracker: style fixes to IconCache


# f2ed47616f4f884a7ef41ed70cb54b82193970a5 20-Jun-2014 John Scipione <jscipione@gmail.com>

Tracker: style fixes to IconCache


# 38fa81bf8f0ccc37a615a9f5bd333f9b781322b3 03-Oct-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

Remove B_COMMON*_DIRECTORY and kCommon*Directory constants

* This does intentionally break source compatibility, so that a review
of concerned code is forced.
* Binary compatibility should be maintained in most cases. The values
of the constants for the writable directories are now used for the
writable system directories. The values for the non-writable
directories are mapped to "/boot/system/data/empty/...", an empty or
non-existent directory, so that they will simply be skipped in search
paths. Only code that explicitly expects to find something in a
B_COMMON_* directory, will fail.


# db41683495bfde817554415d14ae6f9cc91e77eb 02-Jan-2013 Matt Madia <mattmadia@gmail.com>

Automatic whitespace cleanup. No functional change.


# a51764c53eecd8ca5f6312b92d8baccda89d5b1d 27-Jul-2012 John Scipione <jscipione@gmail.com>

WIP: Yet more style fixes, mostly 80 char violations.


# b05aa8b5b16e5b4f420a35c37805c6387df98737 27-Jul-2012 John Scipione <jscipione@gmail.com>

Style changes in Tracker, no functional change.

Manual whitespace cleanup
Change instances of const char * to const char*
Convert /* */ C style comments to // C++ style comments


# aa56e459e04193abdd8da91e1eb283869233627b 20-Jun-2011 Jérôme Duval <korli@users.berlios.de>

revert r42251. Cast the enum to uint32 before use in switchs to please GCC 4.5.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42266 a95241bf-73f2-0310-859d-f6bbb57e9c96


# aa61ee48ef2a616cf1b459f335f97b34de83f66f 17-Jan-2010 Rene Gollent <anevilyak@gmail.com>

Cleaned up legacy icon mappings and add some missing resource definitions to
TrackerIcons.h. Also removed the setup for the folder icon mimetype in
TrackerInitialState, as it was using a non-existent resource ID to do so with.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35118 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 5422febd0b2a2830c47e56970b37e56258262c32 14-Jul-2009 Stephan Aßmus <superstippi@gmx.de>

Fixed a few coding style violations and GCC4 warnings.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31555 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 4fba3522e02906506b6c713ef5b57d72e9458fef 11-Apr-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* Removed src/kits/tracker/OpenHashTable.h. The shared version in
headers/private/shared is newer, though with small interface changes.
* Removed the unnecessary Debug.h include in
headers/private/shared/ObjectList.h.
* Adjusted sources using these headers, mostly by adding missing includes.
* Lots of automatic whitespace cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30123 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 67fb7cd0ed2e0810937285af04f6934423f5d96a 28-Mar-2007 Axel Dörfler <axeld@pinc-software.de>

Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20443 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a803529b13a3dc2a04c7afc6134831f2179e72a3 19-Jan-2007 Axel Dörfler <axeld@pinc-software.de>

As Marcus noticed, some icons were gone after my last change; in fact no icons
were shown for all files without an own icon, and without one from its MIME type.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19866 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8cddf1913200209f1489fda193cfe235c0b204cb 16-Jan-2007 Axel Dörfler <axeld@pinc-software.de>

Tracker now prefers an icon coming directly from the MIME type over one specified
by the application - as FileTypes already did.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19829 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 358b3c8e76e6a86c099a6d87753927d7f429537e 14-Sep-2006 Stephan Aßmus <superstippi@gmx.de>

* don't mess so much with the drawing and blending mode when
drawing icons, most importantly, don't switch from compositing
to pixel alpha, this fixes the drag bitmap generation, now
it looks beautiful


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18846 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7fb6186f3cb93a14ea0f96a82bdfc3d18f3ad56e 29-Aug-2006 Stephan Aßmus <superstippi@gmx.de>

* integration of vector icons with the registrar and the mime data base
* additional versions of SetIcon[ForType] and GetIcon[ForType] in BMimeType
and BAppFileInfo, which handle flat vector icon data
* changes in Tracker to support scalable icons (currently broken for
non-vector icons and needs cleanup) and drawing icons correctly with alpha
channel (large parts of this work done by Michael Lotz)

If someone feels like looking over the changes, that would be much
appreciated! :-)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18699 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 9ecf9d1c1d4888d341a6eac72112c72d1ae3a4cb 26-Aug-2006 Ingo Weinhold <ingo_weinhold@gmx.de>

Merge from layout management branch.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18649 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e68b7626597f4665e41aa23be48748cfd79ef0e4 11-Dec-2005 Axel Dörfler <axeld@pinc-software.de>

More GCC 4 fixes by Ingo Weinhold - appeared because of the recent removal
of new/typeinfo/exception from our headers.
Rearranged the IconCache node_ref hash computation to be padding-resistant
(at least on PPC, node_ref is 16 bytes long, not 12 as it is with x86 and GCC 2).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15498 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 59e89c60523473529dd05baaff2f52228d47c366 26-Nov-2005 Axel Dörfler <axeld@pinc-software.de>

Fixed a locking bug in the icon cache.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15172 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 02be5353fd41ea40007a382e13f007eaf6b5a3a0 22-May-2005 Axel Dörfler <axeld@pinc-software.de>

Added libtracker.so to the repository and the build.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12772 a95241bf-73f2-0310-859d-f6bbb57e9c96