From 2686c2ca03e8f78deefd6fa3d7ae561d146a1610 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Dzi=C4=99giel?= Date: Fri, 27 Aug 2021 13:30:08 +0200 Subject: [PATCH] Quietly handle ranking gsetting change after app update Do not print errors for everyone who updates Clapper from 0.3.0 version. How plugin ranking is stored in gsettings changed. Instead reset it quietly into new defaults to avoid problems. Also since now GstClapper API sets some default ranks based on installed GStreamer version, hopefully this ranking will be only an edge case for people who want to experiment or need to test/debug some GStreamer plugin. --- src/player.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/player.js b/src/player.js index 1d07d06d..6692df43 100644 --- a/src/player.js +++ b/src/player.js @@ -97,18 +97,24 @@ class ClapperPlayer extends GstClapper.Clapper set_all_plugins_ranks() { let data = {}; + let hadErr = false; /* Set empty plugin list if someone messed it externally */ try { data = JSON.parse(settings.get_string('plugin-ranking')); if(Array.isArray(data)) { data = {}; - throw new Error('plugin ranking data is not an object'); + hadErr = true; } } catch(err) { debug(err); + hadErr = true; + } + + if(hadErr) { settings.set_string('plugin-ranking', "{}"); + debug('restored plugin ranking to defaults'); } for(let plugin of Object.keys(data))