Skip to content

Commit

Permalink
Remove Dynamic Theme & Locale listeners by Id
Browse files Browse the repository at this point in the history
  • Loading branch information
rad-pat committed Nov 6, 2024
1 parent 2b77b07 commit 2cab79d
Show file tree
Hide file tree
Showing 17 changed files with 71 additions and 107 deletions.
10 changes: 4 additions & 6 deletions source/class/qx/ui/basic/Label.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ qx.Class.define("qx.ui.basic.Label", {
}

if (qx.core.Environment.get("qx.dynlocale")) {
qx.locale.Manager.getInstance().addListener(
this.__changeLocaleLabelListenerId = qx.locale.Manager.getInstance().addListener(
"changeLocale",
this._onChangeLocale,
this
Expand Down Expand Up @@ -529,11 +529,9 @@ qx.Class.define("qx.ui.basic.Label", {
*/

destruct() {
if (qx.core.Environment.get("qx.dynlocale")) {
qx.locale.Manager.getInstance().removeListener(
"changeLocale",
this._onChangeLocale,
this
if (qx.core.Environment.get("qx.dynlocale") && this.__changeLocaleLabelListenerId) {
qx.locale.Manager.getInstance().removeListenerById(
this.__changeLocaleLabelListenerId
);
}

Expand Down
10 changes: 4 additions & 6 deletions source/class/qx/ui/control/DateChooser.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ qx.Class.define("qx.ui.control.DateChooser", {

// listen for locale changes
if (qx.core.Environment.get("qx.dynlocale")) {
qx.locale.Manager.getInstance().addListener(
this.__changeLocaleDatePaneListenerId = qx.locale.Manager.getInstance().addListener(
"changeLocale",
this._updateDatePane,
this
Expand Down Expand Up @@ -782,11 +782,9 @@ qx.Class.define("qx.ui.control.DateChooser", {
*/

destruct() {
if (qx.core.Environment.get("qx.dynlocale")) {
qx.locale.Manager.getInstance().removeListener(
"changeLocale",
this._updateDatePane,
this
if (qx.core.Environment.get("qx.dynlocale") && this.__changeLocaleDatePaneListenerId) {
qx.locale.Manager.getInstance().removeListenerById(
this.__changeLocaleDatePaneListenerId
);
}

Expand Down
10 changes: 4 additions & 6 deletions source/class/qx/ui/core/Blocker.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ qx.Class.define("qx.ui.core.Blocker", {

// dynamic theme switch
if (qx.core.Environment.get("qx.dyntheme")) {
qx.theme.manager.Meta.getInstance().addListener(
this.__changeThemeBlockerListenerId = qx.theme.manager.Meta.getInstance().addListener(
"changeTheme",
this._onChangeTheme,
this
Expand Down Expand Up @@ -499,11 +499,9 @@ qx.Class.define("qx.ui.core.Blocker", {

destruct() {
// remove dynamic theme listener
if (qx.core.Environment.get("qx.dyntheme")) {
qx.theme.manager.Meta.getInstance().removeListener(
"changeTheme",
this._onChangeTheme,
this
if (qx.core.Environment.get("qx.dyntheme") && this.__changeThemeBlockerListenerId) {
qx.theme.manager.Meta.getInstance().removeListenerById(
this.__changeThemeBlockerListenerId
);
}

Expand Down
10 changes: 4 additions & 6 deletions source/class/qx/ui/core/LayoutItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ qx.Class.define("qx.ui.core.LayoutItem", {

// dynamic theme switch
if (qx.core.Environment.get("qx.dyntheme")) {
qx.theme.manager.Meta.getInstance().addListener(
this.__changeThemeLayoutItemListenerId = qx.theme.manager.Meta.getInstance().addListener(
"changeTheme",
this._onChangeTheme,
this
Expand Down Expand Up @@ -933,11 +933,9 @@ qx.Class.define("qx.ui.core.LayoutItem", {

destruct() {
// remove dynamic theme listener
if (qx.core.Environment.get("qx.dyntheme")) {
qx.theme.manager.Meta.getInstance().removeListener(
"changeTheme",
this._onChangeTheme,
this
if (qx.core.Environment.get("qx.dyntheme") && this.__changeThemeLayoutItemListenerId) {
qx.theme.manager.Meta.getInstance().removeListenerById(
this.__changeThemeLayoutItemListenerId
);
}
this.$$parent =
Expand Down
10 changes: 4 additions & 6 deletions source/class/qx/ui/form/AbstractField.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ qx.Class.define("qx.ui.form.AbstractField", {

// translation support
if (qx.core.Environment.get("qx.dynlocale")) {
qx.locale.Manager.getInstance().addListener(
this.__changeLocaleAbstractFieldListenerId = qx.locale.Manager.getInstance().addListener(
"changeLocale",
this._onChangeLocale,
this
Expand Down Expand Up @@ -1074,11 +1074,9 @@ qx.Class.define("qx.ui.form.AbstractField", {

this._placeholder = this.__font = null;

if (qx.core.Environment.get("qx.dynlocale")) {
qx.locale.Manager.getInstance().removeListener(
"changeLocale",
this._onChangeLocale,
this
if (qx.core.Environment.get("qx.dynlocale") && this.__changeLocaleAbstractFieldListenerId) {
qx.locale.Manager.getInstance().removeListenerById(
this.__changeLocaleAbstractFieldListenerId
);
}

Expand Down
10 changes: 4 additions & 6 deletions source/class/qx/ui/form/MForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
qx.Mixin.define("qx.ui.form.MForm", {
construct() {
if (qx.core.Environment.get("qx.dynlocale")) {
qx.locale.Manager.getInstance().addListener(
this.__changeLocaleMFormListenerId = qx.locale.Manager.getInstance().addListener(
"changeLocale",
this.__onChangeLocale,
this
Expand Down Expand Up @@ -103,11 +103,9 @@ qx.Mixin.define("qx.ui.form.MForm", {
},

destruct() {
if (qx.core.Environment.get("qx.dynlocale")) {
qx.locale.Manager.getInstance().removeListener(
"changeLocale",
this.__onChangeLocale,
this
if (qx.core.Environment.get("qx.dynlocale") && this.__changeLocaleMFormListenerId) {
qx.locale.Manager.getInstance().removeListenerById(
this.__changeLocaleMFormListenerId
);
}
}
Expand Down
10 changes: 4 additions & 6 deletions source/class/qx/ui/form/Spinner.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ qx.Class.define("qx.ui.form.Spinner", {
this.addListener("roll", this._onRoll, this);

if (qx.core.Environment.get("qx.dynlocale")) {
qx.locale.Manager.getInstance().addListener(
this.__changeLocaleSpinnerListenerId = qx.locale.Manager.getInstance().addListener(
"changeLocale",
this._onChangeLocale,
this
Expand Down Expand Up @@ -800,11 +800,9 @@ qx.Class.define("qx.ui.form.Spinner", {
nf.removeListener("changeNumberFormat", this._onChangeNumberFormat, this);
}

if (qx.core.Environment.get("qx.dynlocale")) {
qx.locale.Manager.getInstance().removeListener(
"changeLocale",
this._onChangeLocale,
this
if (qx.core.Environment.get("qx.dynlocale") && this.__changeLocaleSpinnerListenerId) {
qx.locale.Manager.getInstance().removeListenerById(
this.__changeLocaleSpinnerListenerId
);
}
}
Expand Down
10 changes: 4 additions & 6 deletions source/class/qx/ui/form/renderer/AbstractRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ qx.Class.define("qx.ui.form.renderer.AbstractRenderer", {

// translation support
if (qx.core.Environment.get("qx.dynlocale")) {
qx.locale.Manager.getInstance().addListener(
this.__changeLocaleRendererListenerId = qx.locale.Manager.getInstance().addListener(
"changeLocale",
this._onChangeLocale,
this
Expand Down Expand Up @@ -190,11 +190,9 @@ qx.Class.define("qx.ui.form.renderer.AbstractRenderer", {
*/

destruct() {
if (qx.core.Environment.get("qx.dynlocale")) {
qx.locale.Manager.getInstance().removeListener(
"changeLocale",
this._onChangeLocale,
this
if (qx.core.Environment.get("qx.dynlocale") && this.__changeLocaleRendererListenerId) {
qx.locale.Manager.getInstance().removeListenerById(
this.__changeLocaleRendererListenerId
);
}
this._names = null;
Expand Down
18 changes: 7 additions & 11 deletions source/class/qx/ui/menu/AbstractButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,17 +265,15 @@ qx.Class.define("qx.ui.menu.AbstractButton", {
if (qx.core.Environment.get("qx.dynlocale")) {
var oldCommand = e.getOldData();
if (!oldCommand) {
qx.locale.Manager.getInstance().addListener(
this.__changeLocaleCommandListenerId = qx.locale.Manager.getInstance().addListener(
"changeLocale",
this._onChangeLocale,
this
);
}
if (!command) {
qx.locale.Manager.getInstance().removeListener(
"changeLocale",
this._onChangeLocale,
this
if (!command && this.__changeLocaleCommandListenerId) {
qx.locale.Manager.getInstance().removeListenerById(
this.__changeLocaleCommandListenerId
);
}
}
Expand Down Expand Up @@ -397,11 +395,9 @@ qx.Class.define("qx.ui.menu.AbstractButton", {
}
}

if (qx.core.Environment.get("qx.dynlocale")) {
qx.locale.Manager.getInstance().removeListener(
"changeLocale",
this._onChangeLocale,
this
if (qx.core.Environment.get("qx.dynlocale") && this.__changeLocaleCommandListenerId) {
qx.locale.Manager.getInstance().removeListenerById(
this.__changeLocaleCommandListenerId
);
}
}
Expand Down
10 changes: 4 additions & 6 deletions source/class/qx/ui/mobile/basic/Label.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ qx.Class.define("qx.ui.mobile.basic.Label", {
this.initWrap();

if (qx.core.Environment.get("qx.dynlocale")) {
qx.locale.Manager.getInstance().addListener(
this.__changeLocaleLabelListenerId = qx.locale.Manager.getInstance().addListener(
"changeLocale",
this._onChangeLocale,
this
Expand Down Expand Up @@ -145,11 +145,9 @@ qx.Class.define("qx.ui.mobile.basic.Label", {
*/

destruct() {
if (qx.core.Environment.get("qx.dynlocale")) {
qx.locale.Manager.getInstance().removeListener(
"changeLocale",
this._onChangeLocale,
this
if (qx.core.Environment.get("qx.dynlocale") && this.__changeLocaleLabelListenerId) {
qx.locale.Manager.getInstance().removeListenerById(
this.__changeLocaleLabelListenerId
);
}
}
Expand Down
10 changes: 4 additions & 6 deletions source/class/qx/ui/mobile/form/Label.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ qx.Class.define("qx.ui.mobile.form.Label", {
this.initWrap();

if (qx.core.Environment.get("qx.dynlocale")) {
qx.locale.Manager.getInstance().addListener(
this.__changeLocaleLabelListenerId = qx.locale.Manager.getInstance().addListener(
"changeLocale",
this._onChangeLocale,
this
Expand Down Expand Up @@ -242,11 +242,9 @@ qx.Class.define("qx.ui.mobile.form.Label", {

this.__forWidget = null;
}
if (qx.core.Environment.get("qx.dynlocale")) {
qx.locale.Manager.getInstance().removeListener(
"changeLocale",
this._onChangeLocale,
this
if (qx.core.Environment.get("qx.dynlocale") && this.__changeLocaleLabelListenerId) {
qx.locale.Manager.getInstance().removeListenerById(
this.__changeLocaleLabelListenerId
);
}
}
Expand Down
10 changes: 4 additions & 6 deletions source/class/qx/ui/mobile/list/List.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ qx.Class.define("qx.ui.mobile.list.List", {
}

if (qx.core.Environment.get("qx.dynlocale")) {
qx.locale.Manager.getInstance().addListener(
this.__changeLocaleListListenerId = qx.locale.Manager.getInstance().addListener(
"changeLocale",
this._onChangeLocale,
this
Expand Down Expand Up @@ -615,11 +615,9 @@ qx.Class.define("qx.ui.mobile.list.List", {
destruct() {
this.__trackElement = null;
this._disposeObjects("__provider");
if (qx.core.Environment.get("qx.dynlocale")) {
qx.locale.Manager.getInstance().removeListener(
"changeLocale",
this._onChangeLocale,
this
if (qx.core.Environment.get("qx.dynlocale") && this.__changeLocaleListListenerId) {
qx.locale.Manager.getInstance().removeListenerById(
this.__changeLocaleListListenerId
);
}
}
Expand Down
10 changes: 4 additions & 6 deletions source/class/qx/ui/progressive/renderer/table/cell/Boolean.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ qx.Class.define("qx.ui.progressive.renderer.table.cell.Boolean", {

// dynamic theme switch
if (qx.core.Environment.get("qx.dyntheme")) {
qx.theme.manager.Meta.getInstance().addListener(
this.__changeThemeBooleanCellListenerId = qx.theme.manager.Meta.getInstance().addListener(
"changeTheme",
this._resolveImages,
this
Expand Down Expand Up @@ -177,11 +177,9 @@ qx.Class.define("qx.ui.progressive.renderer.table.cell.Boolean", {
this._iconUrlTrue = this._iconUrlFalse = null;

// remove dynamic theme listener
if (qx.core.Environment.get("qx.dyntheme")) {
qx.theme.manager.Meta.getInstance().removeListener(
"changeTheme",
this._resolveImages,
this
if (qx.core.Environment.get("qx.dyntheme") && this.__changeThemeBooleanCellListenerId) {
qx.theme.manager.Meta.getInstance().removeListenerById(
this.__changeThemeBooleanCellListenerId
);
}
}
Expand Down
10 changes: 4 additions & 6 deletions source/class/qx/ui/table/Table.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ qx.Class.define("qx.ui.table.Table", {

// add an event listener which updates the table content on locale change
if (qx.core.Environment.get("qx.dynlocale")) {
qx.locale.Manager.getInstance().addListener(
this.__changeLocaleTableListenerId = qx.locale.Manager.getInstance().addListener(
"changeLocale",
this._onChangeLocale,
this
Expand Down Expand Up @@ -2164,11 +2164,9 @@ qx.Class.define("qx.ui.table.Table", {

destruct() {
// remove the event listener which handled the locale change
if (qx.core.Environment.get("qx.dynlocale")) {
qx.locale.Manager.getInstance().removeListener(
"changeLocale",
this._onChangeLocale,
this
if (qx.core.Environment.get("qx.dynlocale") && this.__changeLocaleTableListenerId) {
qx.locale.Manager.getInstance().removeListenerById(
this.__changeLocaleTableListenerId
);
}

Expand Down
10 changes: 4 additions & 6 deletions source/class/qx/ui/table/cellrenderer/Abstract.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ qx.Class.define("qx.ui.table.cellrenderer.Abstract", {

// add dynamic theme listener
if (qx.core.Environment.get("qx.dyntheme")) {
qx.theme.manager.Meta.getInstance().addListener(
this.__changeThemeCellRendererListenerId = qx.theme.manager.Meta.getInstance().addListener(
"changeTheme",
this._onChangeTheme,
this
Expand Down Expand Up @@ -242,11 +242,9 @@ qx.Class.define("qx.ui.table.cellrenderer.Abstract", {

destruct() {
// remove dynamic theme listener
if (qx.core.Environment.get("qx.dyntheme")) {
qx.theme.manager.Meta.getInstance().removeListener(
"changeTheme",
this._onChangeTheme,
this
if (qx.core.Environment.get("qx.dyntheme") && this.__changeThemeCellRendererListenerId) {
qx.theme.manager.Meta.getInstance().removeListenerById(
this.__changeThemeCellRendererListenerId
);
}
}
Expand Down
10 changes: 4 additions & 6 deletions source/class/qx/ui/table/cellrenderer/Boolean.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ qx.Class.define("qx.ui.table.cellrenderer.Boolean", {

// dynamic theme switch
if (qx.core.Environment.get("qx.dyntheme")) {
qx.theme.manager.Meta.getInstance().addListener(
this.__changeThemeBoolCellRendererListenerId = qx.theme.manager.Meta.getInstance().addListener(
"changeTheme",
this._onChangeTheme,
this
Expand Down Expand Up @@ -172,11 +172,9 @@ qx.Class.define("qx.ui.table.cellrenderer.Boolean", {
destruct() {
this.__aliasManager = null;
// remove dynamic theme listener
if (qx.core.Environment.get("qx.dyntheme")) {
qx.theme.manager.Meta.getInstance().removeListener(
"changeTheme",
this._onChangeTheme,
this
if (qx.core.Environment.get("qx.dyntheme") && this.__changeThemeBoolCellRendererListenerId) {
qx.theme.manager.Meta.getInstance().removeListenerById(
this.__changeThemeBoolCellRendererListenerId
);
}
}
Expand Down
Loading

0 comments on commit 2cab79d

Please sign in to comment.