appIndicator: Do not log critical errors on null GIcon's if there are no errors
It may be legit to have null icons, but this is an issue only if due to
an actual error, so filter them more.
Marco Trevisan (TreviƱo)
1 year, 7 months ago
902 | 902 | this.set_icon_size(iconSize); |
903 | 903 | } else { |
904 | 904 | this.gicon = null; |
905 | Util.Logger.debug(`unable to update icon for ${this._indicator.id}`); | |
906 | 905 | } |
907 | 906 | } else if (gicon) { |
908 | 907 | this._emblem = new Gio.Emblem({ icon: gicon }); |
911 | 910 | gicon.inUse = true; |
912 | 911 | } else { |
913 | 912 | this._emblem = null; |
914 | Util.Logger.debug(`unable to update icon emblem for ${this._indicator.id}`); | |
915 | 913 | } |
916 | 914 | |
917 | 915 | if (this.gicon) { |
938 | 936 | } |
939 | 937 | |
940 | 938 | const [name, pixmap, theme] = icon; |
941 | let gicon = null; | |
942 | 939 | const commonArgs = [theme, iconType, iconSize]; |
943 | 940 | |
944 | 941 | if (this._customIcons.size) { |
945 | 942 | let customIcon = this._customIcons.get(iconType); |
946 | if (customIcon) | |
947 | gicon = await this._createIcon(customIcon, null, ...commonArgs); | |
948 | else if (iconType === SNIconType.OVERLAY) | |
949 | return; | |
950 | ||
951 | if (!gicon && iconType !== SNIconType.NORMAL) { | |
952 | customIcon = this._customIcons.get(SNIconType.NORMAL); | |
953 | gicon = await this._createIcon(customIcon, null, ...commonArgs); | |
943 | if (!await this._createAndSetIcon(customIcon, null, ...commonArgs)) { | |
944 | if (iconType !== SNIconType.OVERLAY) { | |
945 | customIcon = this._customIcons.get(SNIconType.NORMAL); | |
946 | this._createAndSetIcon(customIcon, null, ...commonArgs); | |
947 | } | |
954 | 948 | } |
955 | 949 | } else { |
956 | gicon = await this._createIcon(name, pixmap, ...commonArgs); | |
950 | this._createAndSetIcon(name, pixmap, ...commonArgs); | |
951 | } | |
952 | } | |
953 | ||
954 | async _createAndSetIcon(name, pixmap, theme, iconType, iconSize) { | |
955 | let gicon = null; | |
956 | ||
957 | try { | |
958 | gicon = await this._createIcon(name, pixmap, theme, iconType, iconSize); | |
959 | } catch (e) { | |
960 | if (e.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.CANCELLED) || | |
961 | e.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.PENDING)) { | |
962 | Util.Logger.debug(`${this._indicator.id}, Impossible to load icon: ${e}`); | |
963 | return null; | |
964 | } | |
965 | ||
966 | if (iconType === SNIconType.OVERLAY) | |
967 | logError(e, `unable to update icon emblem for ${this._indicator.id}`); | |
968 | else | |
969 | logError(e, `unable to update icon for ${this._indicator.id}`); | |
957 | 970 | } |
958 | 971 | |
959 | 972 | try { |
960 | 973 | this._setGicon(iconType, gicon, iconSize); |
974 | return gicon; | |
961 | 975 | } catch (e) { |
962 | 976 | logError(e, 'Setting GIcon failed'); |
977 | return null; | |
963 | 978 | } |
964 | 979 | } |
965 | 980 |