hourglass.cpp: Avoid division by zero if no images are available.

Origin commit data
------------------
Branch: ni/coolstream
Commit: 12a7e32e85
Author: Thilo Graf <dbt@novatux.de>
Date: 2021-10-19 (Tue, 19 Oct 2021)


------------------
No further description and justification available within origin commit message!

------------------
This commit was generated by Migit
This commit is contained in:
2021-10-19 22:35:24 +02:00
committed by vanhofen
parent b046532ff7
commit a51c52ccf2

View File

@@ -55,9 +55,18 @@ CHourGlass::CHourGlass( const int x_pos,
initImageFiles();
hg_file_num = 0;
hg_interval = interval == HG_AUTO_PAINT_INTERVAL ? (int64_t)(1000/hg_img_files.size()) : interval;
hg_timer = new CComponentsTimer(hg_interval);
hg_timer->OnTimer.connect(sigc::bind(sigc::mem_fun(*this, &CHourGlass::paint), true));
if (!hg_img_files.empty())
{
hg_interval = interval == HG_AUTO_PAINT_INTERVAL ? (int64_t)(1000/hg_img_files.size()) : interval;
hg_timer = new CComponentsTimer(hg_interval);
hg_timer->OnTimer.connect(sigc::bind(sigc::mem_fun(*this, &CHourGlass::paint), true));
}
else
{
hg_timer = NULL;
hg_interval = 0;
dprintf(DEBUG_NORMAL, "[CHourGlass] [%s - %d] NOTE: No %s-images found..\n", __func__, __LINE__, hg_image_basename.c_str());
}
}
CHourGlass::~CHourGlass()