Ticket #6782: weather_screens.2.patch

File weather_screens.2.patch, 3.0 KB (added by Marc Alban <marcalban@…>, 15 years ago)

Updated patch without the memory leak.

  • mythplugins/mythweather/mythweather/weatherSetup.cpp

     
    110110        m_sourceManager->findScriptsDB();
    111111        m_sourceManager->setupSources();
    112112    }
     113   
     114    // Deallocate the ScreenListInfo objects created for the active screen list.
     115    for (int i=0; i < m_activeList->GetCount(); i++)
     116    {
     117        MythUIButtonListItem *item = m_activeList->GetItemAt(i);
     118        if (item->GetData().isValid())
     119            delete qVariantValue<ScreenListInfo *>(item->GetData());
     120    }
    113121}
    114122
    115123bool ScreenSetup::Create()
     
    264272
    265273    QStringList types;
    266274
    267     ScreenListMap m_ScreenListMap = loadScreens();
     275    ScreenListMap screenListMap = loadScreens();
    268276
    269     ScreenListMap::const_iterator i = m_ScreenListMap.constBegin();
    270     while (i != m_ScreenListMap.constEnd())
     277    ScreenListMap::const_iterator i = screenListMap.constBegin();
     278    while (i != screenListMap.constEnd())
    271279    {
    272280
    273         si = m_ScreenListMap[i.key()];
     281        si = screenListMap[i.key()];
    274282        types = si->dataTypes;
    275283        si->units = ENG_UNITS;
    276284
     
    329337        QString src = db.value(4).toString();
    330338        uint draworder = db.value(5).toUInt();
    331339
    332         si = m_ScreenListMap[name];
    333         // Clear types first as we will re-insert the values from the database
    334         si->types.clear();
    335         types = si->dataTypes;
     340        types = screenListMap[name]->dataTypes;
    336341
    337342        TypeListInfo ti(dataitem, location,
    338343                        m_sourceManager->getSourceByName(src));
    339344
    340345        if (active_screens.find(draworder) == active_screens.end())
    341346        {
     347            si = new ScreenListInfo(*screenListMap[name]);
     348            // Clear types first as we will re-insert the values from the database
     349                        si->types.clear();
     350                        si->units = units;
     351           
    342352            MythUIButtonListItem *item =
    343353                new MythUIButtonListItem(m_activeList, name);
    344             si->units = units;
    345 
     354           
    346355            // Only insert types meant for this screen
    347356            for (QStringList::Iterator type_i = types.begin();
    348357                 type_i != types.end(); ++type_i )
  • mythplugins/mythweather/mythweather/weatherUtils.h

     
    5151class ScreenListInfo
    5252{
    5353  public:
     54        ScreenListInfo() {}
     55    ScreenListInfo(const ScreenListInfo &info)
     56        : name(info.name), types(info.types), dataTypes(info.dataTypes),
     57        helptxt(info.helptxt), sources(info.sources), units(info.units),
     58        hasUnits(info.hasUnits), multiLoc(info.multiLoc)
     59    {
     60        types.detach();
     61    }
     62       
    5463    TypeListInfo GetCurrentTypeList(void) const;
    5564
    5665  public: