Miranda NG Official Community Forum

Forum for English speaking Miranda NG users => Bug reports => Topic started by: hydrogen fluoride on 29 10 2022, 22:21:20

Title: Core: MIR_APP_DLL(int) Srmm_RemoveButton(BBButton *bbdi) is broken
Post by: hydrogen fluoride on 29 10 2022, 22:21:20
Original code:

MIR_APP_DLL(int) Srmm_RemoveButton(BBButton *bbdi)
{
    if (!bbdi)
        return 1;
    CustomButtonData *pFound = nullptr;
   {
        mir_cslock lck(csToolBar);
        for (auto &cbd : arButtonsList.rev_iter())
            if (!mir_strcmp(cbd->m_pszModuleName, bbdi->pszModuleName) && cbd->m_dwButtonID == bbdi->dwButtonID)
                pFound = arButtonsList.removeItem(&cbd);
   }
    if (pFound)
    {
        CSrmmToolbarOptions::RereadButtons();
        WindowList_Broadcast(g_hWindowList, WM_CBD_REMOVED, pFound->m_dwButtonCID, (LPARAM)pFound);
        delete pFound;
    }
    return 0;
}

In my opinion this is not needed. We should not clear memory from buttons while program works.
Meenwhile there is sets of buttons, not an solo buttons.
Also there is build-in Windows instruments to manage GUI elements.