GNOME Bugzilla – Bug 687250
Useless function _setWeekdateHeaderWidth in Calendar class in calendar.js
Last modified: 2012-12-10 21:36:33 UTC
I noticed this function in Calendar in calendar.js: _setWeekdateHeaderWidth: function() { if (this.digitWidth != NaN && this._useWeekdate && this._weekdateHeader) { this._weekdateHeader.set_width (this._digitWidth * WEEKDATE_HEADER_WIDTH_DIGITS); } }, It is called from _styleChanged. However, `this._weekdateHeader` is *never* created anywhere, so this function will *always* do nothing (the if will always fail), and hence can be removed. In fact, the only place `this._weekdateHeader` appears is in this function. This happens from GNOME 3.2 up to 3.6 -- removing all calls to it and the function itself does not seem to cause any errors as far as I can tell (playing with the various date menu settings).
In fact, `this.digitWidth` is a typo in that function anyway; only `this._digitWidth` is ever assigned a value, and even it is *only* used in `_onStyleChange`: _onStyleChange: function(actor, event) { // width of a digit in pango units this._digitWidth = _getDigitWidth(this.actor) / Pango.SCALE; this._setWeekdateHeaderWidth(); }, Given that all `_onStyleChange` does is assign to `this._digitWidth` (which is never used otherwise) and call `this._setWeekdateHeaderWidth` (which will never succeed), the `_onStyleChange` function is also useless. Once I learn how to make a patch, I can put one here! (This is from GNOME 3.2 up to 3.6.1).
Created attachment 230556 [details] [review] Calendar: remove dead code this._weekdateHeader is never assigned, so _setWeekdateHeaderWidth is useless. Everything else falls from that. Spotted by mathematical.coffee@gmail.com, our human coverity :)
Review of attachment 230556 [details] [review]: OK.
Attachment 230556 [details] pushed as 5072ea7 - Calendar: remove dead code