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

This commit is contained in:
2021-10-19 14:43:16 +02:00
parent ca05431f4d
commit b4a3d19c9f

View File

@@ -55,9 +55,18 @@ CHourGlass::CHourGlass( const int x_pos,
initImageFiles(); initImageFiles();
hg_file_num = 0; hg_file_num = 0;
hg_interval = interval == HG_AUTO_PAINT_INTERVAL ? (int64_t)(1000/hg_img_files.size()) : interval; if (!hg_img_files.empty())
hg_timer = new CComponentsTimer(hg_interval); {
hg_timer->OnTimer.connect(sigc::bind(sigc::mem_fun(*this, &CHourGlass::paint), true)); 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() CHourGlass::~CHourGlass()