After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 687250 - Useless function _setWeekdateHeaderWidth in Calendar class in calendar.js
Useless function _setWeekdateHeaderWidth in Calendar class in calendar.js
Status: RESOLVED FIXED
Product: gnome-shell
Classification: Core
Component: calendar
3.6.x
Other Linux
: Normal trivial
: ---
Assigned To: gnome-shell-maint
gnome-shell-maint
Depends on:
Blocks:
 
 
Reported: 2012-10-31 07:45 UTC by mathematical.coffee
Modified: 2012-12-10 21:36 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Calendar: remove dead code (2.94 KB, patch)
2012-12-03 18:22 UTC, Giovanni Campagna
committed Details | Review

Description mathematical.coffee 2012-10-31 07:45:37 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).
Comment 1 mathematical.coffee 2012-10-31 08:08:11 UTC
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).
Comment 2 Giovanni Campagna 2012-12-03 18:22:21 UTC
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 :)
Comment 3 drago01 2012-12-08 11:43:39 UTC
Review of attachment 230556 [details] [review]:

OK.
Comment 4 Giovanni Campagna 2012-12-10 21:36:15 UTC
Attachment 230556 [details] pushed as 5072ea7 - Calendar: remove dead code