Opened 4 years ago

Closed 4 years ago

#16473 closed bug (fixed)

Autoraise icon in sys tray distorted

Reported by: yangh Owned by: ambroff
Priority: normal Milestone: Unscheduled
Component: Applications Version: R1/beta2
Keywords: Cc:
Blocked By: Blocking:
Platform: All

Description (last modified by diver)

Booted up Haiku for about 16 hours. Then I found the Autoraise icon in systray distorted, I still can right-click on it to access menus.

Attachments (1)

VirtualBox_Haiku_11_08_2020_15_02_35-Autoraise-icon-in-systray-distored.png (119.1 KB ) - added by yangh 4 years ago.

Download all attachments as: .zip

Change History (8)

comment:1 by diver, 4 years ago

Component: Preferences/AppearanceApplications
Description: modified (diff)
Owner: changed from nobody to mmu_man
Status: newassigned

comment:2 by ambroff, 4 years ago

I've noticed the same thing and just looked into it. I see the problem.

When the applet loads it creates an instance of TrayView. The constructor calls TrayView::_init(), which loads the bitmaps that are used in the TrayView::Draw().

    BResources res;                                                                     
    BFile theapp(&_appPath, B_READ_ONLY);                                               
    if ((err = res.SetTo(&theapp)) != B_OK) {                                           
                                                                                        
        printf("Unable to find the app to get the resources !!!\n");                    
//      removeFromDeskbar(NULL);                                                        
//      delete _settings;                                                               
//      return;                                                                         
    }                                                                                   
                                                                                        
    size_t bmsz;                                                                        
    char *p;                                                                            
                                                                                        
    p = (char *)res.LoadResource('MICN', ACTIVE_ICON, &bmsz);                           
    _activeIcon = new BBitmap(BRect(0, 0, B_MINI_ICON-1, B_MINI_ICON -1),               
        B_CMAP8);                                                                       
    if (!p)                                                                             
        puts("ERROR loading active icon");                                              
    else                                                                                
        _activeIcon->SetBits(p, B_MINI_ICON*B_MINI_ICON, 0, B_CMAP8);                   
                                                                                        
    p = (char *)res.LoadResource('MICN', INACTIVE_ICON, &bmsz);                         
    _inactiveIcon = new BBitmap(BRect(0, 0, B_MINI_ICON-1, B_MINI_ICON -1),             
        B_CMAP8);                                                                       
    if (!p)                                                                             
        puts("ERROR loading inactive icon");                                            
    else                                                                                
        _inactiveIcon->SetBits(p, B_MINI_ICON*B_MINI_ICON, 0, B_CMAP8); 

So the bitmaps get loaded from resources in the AutoRaise app file which lives in /boot/system/apps/AutoRaise. How does _appPath get initialized?

    _appPath = _settings->AppPath();

Looking at the settings file the answer becomes clear.

~> message ~/config/settings/x-vnd.mmu.AutoRaise_settings 
BMessage(0x0) {
        ar:active = bool(false)
        ar:delay = int64(0x7a120 or 500000)
        ar:mode = int32(0x0 or 0)
        ar:app_path = entry_ref(device=4, directory=1108, name="AutoRaise", path="(null)")
}

So it is supposed to write the path to itself in its settings, and when it is loaded back up, is supposed to use that path to the binary so that it can load the resources. But it's unable to find the file.

And since the error returned from res.SetTo() is ignored, the _activeIcon and _inactiveIcon bitmaps end up containing random garbage.

comment:3 by ambroff, 4 years ago

When you first add it to the deskbar it does write the actual path.

~> message ~/config/settings/x-vnd.mmu.AutoRaise_settings 
BMessage(0x0) {
        ar:active = bool(false)
        ar:delay = int64(0x7a120 or 500000)
        ar:mode = int32(0x0 or 0)
        ar:app_path = entry_ref(device=4, directory=741, name="AutoRaise", path="/boot/system/apps/AutoRaise")
}

The directory entry changed. I suspect that the problem is that persisting an entry_ref for a file from packagefs doesn't work because the device and directory aren't stable across reboots?

comment:4 by ambroff, 4 years ago

Anyway this is easy to fix by just getting the path using our_image() trick that other tray applets use, rather than storing the path in the settings.

comment:5 by ambroff, 4 years ago

Owner: changed from mmu_man to ambroff

comment:6 by ambroff, 4 years ago

Fixed in hrev54671.

comment:7 by ambroff, 4 years ago

Resolution: fixed
Status: assignedclosed
Note: See TracTickets for help on using tickets.