Page 1 of 1

wxTaskBarIcon using a TFF

Posted: Tue Nov 22, 2016 12:00 pm
by ChronoGraff
Hi guys, my first post. **edit** not my first post... hmm... :shock:

This is driving me crazy, I have looked at the Resources of other apps and notice tiff's being used.

My basic code is:

Code: Select all

// .xpm format
if (!_systemTray->SetIcon(wxICON(tray_icon), "Today's tasks."))
{
    // Deal with error
}

// .tiff format
wxIcon icon(_("tray_icon"), wxBITMAP_TYPE_TIFF);
if (!_systemTray->SetIcon(icon, "Today's tasks."))
{
    // Deal with error
}
And the trace:

Code: Select all

Exception Type:        EXC_BAD_ACCESS (SIGSEGV)
Exception Codes:       KERN_INVALID_ADDRESS at 0x0000000000000058
Exception Note:        EXC_CORPSE_NOTIFY

VM Regions Near 0x58:
--> 
    __TEXT                 00000001091da000-000000010925d000 [  524K] r-x/rwx SM=COW  /Volumes/VOLUME/*/ChronoGraff.app/Contents/MacOS/ChronoGraff

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   libwx_osx_cocoau_core-3.1.dylib	0x0000000109578bb3[b] wxBitmap::GetNSImage() const + 51[/b]
1   libwx_osx_cocoau_adv-3.1.dylib	0x0000000109a87ead wxTaskBarIconCustomStatusItemImpl::SetIcon(wxIcon const&, wxString const&) + 429
I am assuming that line 0 (bolded) is where the issue lies.

I have NO idea how to use a tiff instead of xpm, or in fact load a taskbaricon of another format other than xpm. It's a real pain at the moment, this is a kind of last resort posting here as I have spent a few days trying all manner of solutions to no avail.

Can anyone help? Thanks in advance

Re: wxTaskBarIcon using a TFF

Posted: Tue Nov 22, 2016 12:36 pm
by doublemax

Code: Select all

wxIcon icon(_("tray_icon"), wxBITMAP_TYPE_TIFF);
After this you should check if the icon is ok before using it ( icon.IsOk() ). Most likely it's not.

Make sure the file is found. Is the filename really "tray_icon", without extension?

Another possibility is that the TIFF image handler is not loaded. Did you call wxInitAllImageHandlers() ?

Re: wxTaskBarIcon using a TFF

Posted: Tue Nov 22, 2016 4:09 pm
by ChronoGraff
doublemax wrote:

Code: Select all

wxIcon icon(_("tray_icon"), wxBITMAP_TYPE_TIFF);
After this you should check if the icon is ok before using it ( icon.IsOk() ). Most likely it's not.

Make sure the file is found. Is the filename really "tray_icon", without extension?

Another possibility is that the TIFF image handler is not loaded. Did you call wxInitAllImageHandlers() ?
Hi thanks for the reply, and I get this;

I also changed "tray_icon" to "tray_icon.tiff"

Code: Select all

16:06:28: can't open file 'tray_icon.tiff' (error 2: No such file or directory)
16:06:28: Failed to load image from file "tray_icon.tiff".
I also have wxInitAllImageHandlers() called in constructer.

One thing, the path? Should the path be relative, or? Is there something I'm missing. It's not finding the file. IsOk() was perfect to figure out what was wrong. Thanks for that! I should have noticed that, just been working hard and a bit tired.

Making headway now at least I know it can't find the file!

Re: wxTaskBarIcon using a TFF

Posted: Tue Nov 22, 2016 4:49 pm
by doublemax
Using relative paths is often unreliable, better use wxStandardPaths to build an absolute path.

E.g.

Code: Select all

#include <wx/stdpaths.h>
...
wxString filepath = wxStandardPaths::Get().GetDataDir() + "/tray_icon.tiff";
wxLogMessage("trying to load: %s", filepath );

Re: wxTaskBarIcon using a TFF

Posted: Tue Nov 22, 2016 5:14 pm
by ChronoGraff
Thanks for the help! Appreciated!

Re: wxTaskBarIcon using a TFF

Posted: Tue Nov 22, 2016 5:26 pm
by ChronoGraff
Flip me... spoke too soon... the TIFF is loading, everything is fine BUT

Code: Select all

17:25:16: Unknown field with tag 37724 (0x935c) encountered (in module "TIFFReadDirectory")
17:25:16: Unknown field with tag 37724 (0x935c) encountered (in module "TIFFReadDirectory")
I'm using latest version of libtiff.

Sorted, on OS X use

Code: Select all

tiffutil -cathidpicheck <files> -out <name>.tiff
Taken from https://developer.apple.com/library/con ... 02-CH7-SW4

Re: wxTaskBarIcon using a TFF

Posted: Tue Nov 22, 2016 6:44 pm
by doublemax
In wxWidgets you can suppress these kind of warning messages by creating an instance of wxLogNull on the stack.

http://docs.wxwidgets.org/trunk/classwx_log_null.html