Open Bug 764242 Opened 12 years ago Updated 2 years ago

magicCopy does not respect clipboard.autocopy pref

Categories

(Thunderbird :: Instant Messaging, defect)

defect

Tracking

(Not tracked)

REOPENED

People

(Reporter: Mook, Assigned: Mook)

References

()

Details

Attachments

(1 file, 1 obsolete file)

See URL; setting clipboard.autocopy to false does not disable auto-copy when messenger.conversations.selections.magicCopyEnabled is true.
Huh. I had most of the patch sitting around for some reason; must have forgotten about it halfway through trying to build Mozilla (again).
Attachment #778294 - Flags: review?(florian)
Comment on attachment 778294 [details] [diff] [review]
chat: obey clipboard.autoCopy being disabled in magicCopy

Review of attachment 778294 [details] [diff] [review]:
-----------------------------------------------------------------

Thanks for looking into scratching this itch of yours :-).

::: chat/content/convbrowser.xml
@@ +139,2 @@
>        <field name="magicCopyInitialized">false</field>
> +      

Nit: Adding trailing whitespace isn't the best idea ;).

@@ +733,5 @@
>                  this.contentWindow.controllers.insertControllerAt(0, this);
>  
> +                if (this.autoCopyEnabled &&
> +                    Services.clipboard.supportsSelectionClipboard())
> +                {

Nit: The { should stay at the end of the previous line.

@@ +741,5 @@
>                  }
>                }
>                if (!this.magicCopyInitialized) {
>                  Services.prefs.addObserver(this.magicCopyPref, this, false);
> +                Services.prefs.addObserver(this.autoCopyPref, this, false);

Observing this pref on OSes where Services.clipboard.supportsSelectionClipboard() is false seems unfortunate; is it possible to avoid it?

Also, I'm not sure observing changes to this preference is really worth it: it looks like the only place where this pref is used in gecko (http://mxr.mozilla.org/mozilla-central/source/layout/generic/nsSelection.cpp#354) doesn't set observers, so I assume you need to restart any XUL app for changes to this pref to take effect.
How would you feel about just checking the pref value when we are about to add the selection listener, and keeping a boolean indicating if we set a selection listener or not (so that we don't check the pref again at uninitialization, as its value may have changed...).

@@ +1069,5 @@
>  
>            // and our selection listener!
> +          if (this.autoCopyEnabled &&
> +              Services.clipboard.supportsSelectionClipboard())
> +          {

Nit: The { should stay at the end of the previous line.
Attachment #778294 - Flags: review?(florian) → review-
Thanks for the review!

Given that the pref is normally read there anyway (that is: from experimentation, without magicCopy, I can only get it to recognize my changes when I open a new conversation): Changed so we just read the pref once, and keep the same value thereafter.  This actually means the patch can be a lot more minimal now - just check the cached value instead of whether we have support for a primary selection.

The docshell swapping code looks suspicious, though... I'm not convinced it's tearing down and restoring *both* sides correctly.  But that's not limited to the copy stuff, so I'm leaving that alone for now.
Attachment #778294 - Attachment is obsolete: true
Attachment #778811 - Flags: review?(florian)
(In reply to :Mook from comment #3)

> The docshell swapping code looks suspicious, though... I'm not convinced
> it's tearing down and restoring *both* sides correctly.

I'm pretty sure it's broken, as we had to fix it: https://bugzilla.instantbird.org/show_bug.cgi?id=1940
Porting this patch to Instantbird https://bugzilla.instantbird.org/show_bug.cgi?id=2062. The fix will be in TB after the next merge.
As per comment 5, this is now fixed upstream.
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
This is not fixed in Thunderbird, therefore this should stay open until the next merge.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Comment on attachment 778811 [details] [diff] [review]
Only read the pref once

Removing the review request as I think we agreed that the way forward is to merge chat/ again between Instantbird and Thunderbird.
Attachment #778811 - Flags: review?(florian)
Summary: magicCopy does not opy clipboard.autocopy pref → magicCopy does not respect clipboard.autocopy pref
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: