Thanks to visit codestin.com
Credit goes to github.com

Skip to content

using image.Image as colors creates issues when copying in reflectx.SetRobust #1394

@rcoreilly

Description

@rcoreilly

Describe the bug

I added this exception in SetRobust, because otherwise the ploteditor changes the underlying color scheme images, making the entire GUI go bonkers.

	// images should not be copied per content: just set the pointer!
	// otherwise the original images (esp colors!) are altered.
	if img, ok := to.(*image.Image); ok {
		if fimg, ok := from.(image.Image); ok {
			*img = fimg
			return nil
		}
	}

In general there is an ambiguity in copying pointers whether it is "deep" or "shallow". We need to figure out a better general-purpose solution to this issue.

This issue also arises in this case because we made the colors.Scheme colors images instead of underlying color.RGBA -- the images are what we use everywhere because it is the most general representation of color, and it saves having to convert the RGBA to an image in 100's of cases across the codebase.

How to reproduce

comment out the above.,

Example code

No response

Relevant output

No response

Platform

macOS

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working correctlyconfirmedThis bug has been confirmed

    Type

    No type

    Projects

    Status

    Todo

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions