From c0cf3a1d0b4ff74ad43d0489631d4b9582b72d81 Mon Sep 17 00:00:00 2001 From: ConfuSomu Date: Wed, 28 Dec 2022 02:13:05 -0500 Subject: Only initialize each QIcon once --- src/list_item.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/list_item.cpp b/src/list_item.cpp index 6409169..a7fde7e 100644 --- a/src/list_item.cpp +++ b/src/list_item.cpp @@ -2,7 +2,14 @@ #include "types.h" QIcon* choose_icon(StatusType status_type) { - return new QIcon(); // TODO: null icon for the moment + // via the use of `static' in the following switch block, the idea is to only initialize each QIcon type once in the program's lifetime. + + switch (status_type) { + // TODO: only null icon for the moment + default: + static QIcon* icon = new QIcon(); + return icon; + } } ListItem::ListItem(const QString &text, StatusType status_type, QListWidget *parent, int index) : -- cgit v1.2.3-54-g00ecf