Ticket #5875: mythui_mythweather.2.diff

File mythui_mythweather.2.diff, 2.1 KB (added by Marc Alban <marcalban@…>, 15 years ago)

This is based on the patch from stuartm, but adds the missing qVariantFromValue() calls and prevents a segfault when escaping from the units popup.

  • mythweather/mythweather/weatherSetup.cpp

     
    572572
    573573    menuPopup->SetReturnEvent(this, "units");
    574574
    575     menuPopup->AddButton(tr("English Units"), si);
    576     menuPopup->AddButton(tr("SI Units"), si);
     575    menuPopup->AddButton(tr("English Units"), qVariantFromValue(si));
     576    menuPopup->AddButton(tr("SI Units"), qVariantFromValue(si));
    577577}
    578578
    579579void ScreenSetup::deleteScreen()
     
    602602
    603603        if (resultid == "options")
    604604        {
    605             MythUIButtonListItem *item = (MythUIButtonListItem *)dce->GetResultData();
    606             ScreenListInfo *si = (ScreenListInfo *) item->getData();
     605            MythUIButtonListItem *item = qVariantValue<MythUIButtonListItem *>(dce->GetData());
     606            ScreenListInfo *si = qVariantValue<ScreenListInfo *>(item->GetData());
    607607
    608608            if (buttonnum == 0)
    609609            {
     
    629629        }
    630630        else if (resultid == "units")
    631631        {
    632             ScreenListInfo *si = (ScreenListInfo *)dce->GetResultData();
    633             if (buttonnum == 0)
     632            if (buttonnum > -1)
    634633            {
    635                 si->units = ENG_UNITS;
     634                ScreenListInfo *si = qVariantValue<ScreenListInfo *>(dce->GetData());
     635                if (buttonnum == 0)
     636                {
     637                    si->units = ENG_UNITS;
     638                }
     639                else if (buttonnum == 1)
     640                {
     641                    si->units = SI_UNITS;
     642                }
     643                doLocationDialog(si);
    636644            }
    637             else if (buttonnum == 1)
    638             {
    639                 si->units = SI_UNITS;
    640             }
    641             doLocationDialog(si);
    642645        }
    643646        else if (resultid == "location")
    644647        {
    645             ScreenListInfo *si = (ScreenListInfo *)dce->GetResultData();
     648            ScreenListInfo *si = qVariantValue<ScreenListInfo *>(dce->GetData());
    646649            Q3DictIterator<TypeListInfo> it(si->types);
    647650            for (; it.current(); ++it)
    648651            {