CBEBouquetWidget: avoid possible crash if no channels available

This constellation should be rare, but if no channels are available,
bouquet editor will crash here.
Verified on generic pc without tuner and Leaksanitizer.
For tests it's possible to enable the block with an extra
instance of CBouquetManager. So it's still possible to edit bouquets
but without channels.


Origin commit data
------------------
Commit: 7f0f7285e1
Author: Thilo Graf <dbt@novatux.de>
Date: 2022-02-08 (Tue, 08 Feb 2022)
This commit is contained in:
2022-02-08 12:06:18 +01:00
committed by vanhofen
parent de5f97ed8c
commit b8d41208ed

View File

@@ -195,19 +195,36 @@ int CBEBouquetWidget::exec(CMenuTarget* parent, const std::string & /*actionKey*
if (parent)
parent->hide();
Bouquets = &g_bouquetManager->Bouquets;
init();
bool loop = true;
paintHead();
paintBody();
paintFoot();
paintItems();
// Without check, it would crash if no channels are available (verified on generic pc without tuner)
#if 0
// for tests, enable this block
static CBouquetManager bm;
g_bouquetManager = &bm;
Bouquets = &g_bouquetManager->Bouquets;
#endif
if (g_bouquetManager)
{
Bouquets = &g_bouquetManager->Bouquets;
init();
paintHead();
paintBody();
paintFoot();
paintItems();
}
else
{
loop = false;
DisplayErrorMessage("No channels available");
}
bouquetsChanged = false;
uint64_t timeoutEnd = CRCInput::calcTimeoutEnd(*timeout_ptr);
bool loop = true;
while (loop)
{
g_RCInput->getMsgAbsoluteTimeout(&msg, &data, &timeoutEnd);