diff --git a/src/backgrounds.c b/src/backgrounds.c index ad881a51..a426e6c7 100644 --- a/src/backgrounds.c +++ b/src/backgrounds.c @@ -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());