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 688973 - Class naming clashes prevent extensions from installation
Class naming clashes prevent extensions from installation
Status: RESOLVED WONTFIX
Product: gnome-shell
Classification: Core
Component: extensions
3.6.x
Other Linux
: Normal critical
: ---
Assigned To: gnome-shell-maint
gnome-shell-maint
: 688355 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2012-11-24 12:39 UTC by Lukas Knuth
Modified: 2012-12-12 18:53 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
The error from the session log. (2.36 KB, text/x-log)
2012-11-24 12:39 UTC, Lukas Knuth
Details

Description Lukas Knuth 2012-11-24 12:39:28 UTC
Created attachment 229760 [details]
The error from the session log.

Multiple users have reported problems when installing my extension (and others, see https://bugzilla.gnome.org/show_bug.cgi?id=688355). The given error-message (from "~/.cache/gdm/session.log") is attached.

It seems, that the "Type name [X] is already registered"-error is a result of another running extension with a class which has a similar name (see the issue at my extension project: https://bitbucket.org/LukasKnuth/backslide/issue/3)

If this is the case, as an extension-developer, you'll have no choice but to prefix every of your classes with something unique to your extension.

Proposal:

Digging into the sources of the "overrides/GObject.js"-file, I see that you are already prefixing every registered class with "Gjs_" (here: http://git.gnome.org/browse/gjs/tree/modules/overrides/GObject.js#n104).

An idea would be to add the extensions uuid as a prefix, too. This should then simulate a namespace (although the might be a better way...?)
Comment 1 Giovanni Campagna 2012-11-30 17:11:14 UTC
The only way is to never register GTypes in extensions.
Extensions are dynamic modules, and they can be loaded and unloaded - but that's not at all possible for GTypes. Even if gjs was using GTypeModule in a way compatible with extensions (which it is not), we still wouldn't be able to unload.

There is no point in namespacing GTypes, if they still can't be used from extensions, so I'm closing this wontfix.
Comment 2 Lukas Knuth 2012-11-30 17:57:14 UTC
You'll have to further elaborate that. If I understand correctly, all the JavaScript bindings for libraries like Gtk or St use GTypes. How can we avoid using those and write working extensions?

Or is it just the fact that I'm *extending* a GType?
Comment 3 Giovanni Campagna 2012-11-30 18:07:13 UTC
Yes, that's what I meant. If you extend a GObject class (anything from St, Clutter, Gtk, etc.), you're registering a new GType, and that's not possible for extensions.
Obviously, using existing classes, or "extending" them with the delegate pattern used by core shell is fine.
Comment 4 Lukas Knuth 2012-11-30 19:39:17 UTC
This "delegate pattern used by core shell" goes like this?

<code>
const Class = new Lang.Class({
  Name: "Class",
  Extends: St.Button,

  _init:function(){
    // Constructor
  }
)};
<code>

Because then, I'm using the pattern. Also, my extension works fine extending GObjects like this.
Comment 5 Jasper St. Pierre (not reading bugmail) 2012-11-30 19:44:05 UTC
(In reply to comment #4)
>   Extends: St.Button,

That's the issue. The delegate pattern looks like this:

const Class = new Lang.Class({
  Name: "Class",

  _init:function(){
    this.actor = new St.Button();
  }
)};
Comment 6 Lukas Knuth 2012-12-01 00:34:06 UTC
So, it's not really extending, it's more like a proxy...

I have not yet found a situation in which "really" extending GObject types was a problem (other than the name-clashes). In which case will this cause the shell to blow up or any other serious problems?
Comment 7 Jasper St. Pierre (not reading bugmail) 2012-12-01 00:38:59 UTC
If the user wants to update the extension at runtime, or any scenario where the module might get re-evaluated.

The permanence of GTypes is unfortunate, yes, and we'd love to fix it, it's just a hard problem.
Comment 8 Lukas Knuth 2012-12-01 01:20:11 UTC
Okay, I'll keep that in mind for the next update. Thanks for explaining it.
Comment 9 Giovanni Campagna 2012-12-02 23:01:33 UTC
*** Bug 688355 has been marked as a duplicate of this bug. ***
Comment 10 Lukas Knuth 2012-12-12 18:31:19 UTC
Just as a quick follow-up: The gnome-shell classes from "/js/ui" are not GTypes, are they?

I don't seem them extending anything that's not from the shell itself, so I assume simply extending those classes (not using the delegate pattern) is okay?
Comment 11 Giovanni Campagna 2012-12-12 18:53:59 UTC
We have a few layout managers, constraints and StWidgets around, but mostly they're pure JS classes.