background: Discard broken backgrounds when opening configuration dialog

This commit is contained in:
Kim Woelders 2022-05-13 15:35:10 +02:00
parent 3008713107
commit 8878d862fd
1 changed files with 17 additions and 0 deletions

View File

@ -1408,6 +1408,22 @@ typedef struct {
static void BG_RedrawView(Dialog * d);
static void BGSettingsGoTo(Dialog * d, Background * bg);
static void
_BackgroundsClean(void)
{
Background *bg, *tmp;
LIST_FOR_EACH_SAFE(Background, &bg_list, bg, tmp)
{
/* Get full path to files */
_BackgroundGetBgFile(bg);
/* Discard if bg file is given but cannot be found (ignore bad fg) */
if (bg->bg.file && !exists(bg->bg.file))
BackgroundDestroy(bg);
}
}
static void
_DlgApplyBG(Dialog * d, int val __UNUSED__, void *data __UNUSED__)
{
@ -1951,6 +1967,7 @@ _DlgFillBackground(Dialog * d, DItem * table, void *data)
if (!Conf.backgrounds.no_scan)
ScanBackgroundMenu();
_BackgroundsClean();
if (!bg)
bg = DeskBackgroundGet(DesksGetCurrent());