From b4a3d19c9fa503560b52a49018a8cea6a22f94bb Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Tue, 19 Oct 2021 14:43:16 +0200 Subject: [PATCH] hourglass.cpp: Avoid division by zero if no images are available. --- src/gui/widget/hourglass.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/gui/widget/hourglass.cpp b/src/gui/widget/hourglass.cpp index 122307b6d..e556b6f54 100644 --- a/src/gui/widget/hourglass.cpp +++ b/src/gui/widget/hourglass.cpp @@ -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()