diff options
author | Alexander Volkov <avolkov@astralinux.ru> | 2020-04-14 17:34:41 +0200 |
---|---|---|
committer | Kim Woelders <kim@woelders.dk> | 2020-04-14 17:34:41 +0200 |
commit | 204d994d8c3af128d3278e518ccd7316f6ac80d0 (patch) | |
tree | 1435881ecafe91d794046bea33b876e39381dec3 | |
parent | 5db012a35e0a3e28c458a10a48e4fc4d79e678c9 (diff) | |
download | imlib2-204d994d8c3af128d3278e518ccd7316f6ac80d0.tar.gz |
Don't rescan loaders
Summary:
Loaders from a newer version of imlib2 may be incompatible with an
older version of imlib2. Thus already running applications may
stop loading images after system upgrade, which can be extremely
unpleasant for the user.
Reviewers: kwo
Reviewed By: kwo
Differential Revision: https://phab.enlightenment.org/D11678
-rw-r--r-- | src/lib/image.c | 6 | ||||
-rw-r--r-- | src/lib/image.h | 2 | ||||
-rw-r--r-- | src/lib/loaders.c | 44 |
3 files changed, 7 insertions, 45 deletions
diff --git a/src/lib/image.c b/src/lib/image.c index 7f3069f..a2425ad 100644 --- a/src/lib/image.c +++ b/src/lib/image.c @@ -752,8 +752,7 @@ __imlib_LoadImage(const char *file, FILE * fp, ImlibProgressFunction progress, immediate_load = 1; } - /* ok - just check all our loaders are up to date */ - __imlib_RescanLoaders(); + __imlib_LoadAllLoaders(); loader_ret = 0; @@ -1025,8 +1024,7 @@ __imlib_SaveImage(ImlibImage * im, const char *file, return; } - /* ok - just check all our loaders are up to date */ - __imlib_RescanLoaders(); + __imlib_LoadAllLoaders(); /* find the laoder for the format - if its null use the extension */ l = __imlib_FindBestLoaderForFileFormat(file, im->format, 1); diff --git a/src/lib/image.h b/src/lib/image.h index 64ebdb3..bea4f41 100644 --- a/src/lib/image.h +++ b/src/lib/image.h @@ -93,7 +93,7 @@ struct _imlibimagepixmap { }; #endif -void __imlib_RescanLoaders(void); +void __imlib_LoadAllLoaders(void); void __imlib_RemoveAllLoaders(void); ImlibLoader **__imlib_GetLoaderList(void); ImlibLoader *__imlib_FindBestLoaderForFile(const char *file, diff --git a/src/lib/loaders.c b/src/lib/loaders.c index 4b0aa77..aa8b3d6 100644 --- a/src/lib/loaders.c +++ b/src/lib/loaders.c @@ -9,8 +9,6 @@ #include "image.h" #include "loaders.h" -static void __imlib_LoadAllLoaders(void); - static ImlibLoader *loaders = NULL; ImlibLoader ** @@ -73,43 +71,6 @@ __imlib_ConsumeLoader(ImlibLoader * l) free(l); } -void -__imlib_RescanLoaders(void) -{ - static time_t last_scan_time = 0; - static time_t last_modified_system_time = 0; - static int scanned = 0; - time_t current_time; - char do_reload = 0; - - /* dont stat the dir and rescan if we checked in the last 5 seconds */ - current_time = time(NULL); - if ((current_time - last_scan_time) < 5) - return; - - /* ok - was the system loaders dir contents modified ? */ - last_scan_time = current_time; - - current_time = __imlib_FileModDate(__imlib_PathToLoaders()); - if (current_time == 0) - return; /* Loader directory not found */ - if ((current_time > last_modified_system_time) || (!scanned)) - { - /* yup - set the "do_reload" flag */ - do_reload = 1; - last_modified_system_time = current_time; - } - - /* if we dont ned to reload the loaders - get out now */ - if (!do_reload) - return; - - __imlib_RemoveAllLoaders(); - __imlib_LoadAllLoaders(); - - scanned = 1; -} - /* remove all loaders int eh list we have cached so we can re-load them */ void __imlib_RemoveAllLoaders(void) @@ -128,12 +89,15 @@ __imlib_RemoveAllLoaders(void) /* find all the loaders we can find and load them up to see what they can */ /* load / save */ -static void +void __imlib_LoadAllLoaders(void) { int i, num; char **list; + if (loaders) + return; + /* list all the loaders imlib can find */ list = __imlib_ListModules(__imlib_PathToLoaders(), &num); /* no loaders? well don't load anything */ |