hourglass: fix segfault, repeatable with: for(int i = 1; i < 10000; i++){hg.paint();hg.hide();}

This commit is contained in:
Jacek Jendrzej
2021-11-20 10:30:32 +01:00
parent 940d6473d9
commit b0067f83ca
2 changed files with 8 additions and 3 deletions

View File

@@ -70,8 +70,11 @@ CHourGlass::CHourGlass( const int x_pos,
CHourGlass::~CHourGlass()
{
delete hg_timer;
hg_timer = NULL;
if(hg_timer)
{
delete hg_timer;
hg_timer = NULL;
}
}
void CHourGlass::initImageFiles()
@@ -101,6 +104,8 @@ void CHourGlass::paint(const bool &do_save_bg)
if (hg_img_files.empty())
return;
std::lock_guard<std::mutex> g(hg_mutex);
if (hg_file_num > hg_img_files.size()-1)
hg_file_num = 0;

View File

@@ -43,7 +43,7 @@ class CHourGlass : public CComponentsShapeSquare
int64_t hg_interval;
CComponentsTimer *hg_timer;
size_t hg_file_num;
std::mutex hg_mutex;
void initImageFiles();
public:
/**CHourGlass Constructor