https://bugs.kde.org/show_bug.cgi?id=432226

--- Comment #1 from chris.ven...@gmail.com ---
Proposed cause of bug:

The code in the setVisible method in libs/libKis/Channel.cpp looks as follows:

    void Channel::setVisible(bool value)
    {
        if (!d->node || !d->channel) return;
        if (!d->node->inherits("KisLayer")) return;

        for (uint i = 0; i < d->node->colorSpace()->channelCount(); ++i) {
            if (d->node->colorSpace()->channels()[i] == d->channel) {
                QBitArray flags = d->node->colorSpace()->channelFlags(true,
true);
                flags.setBit(i, value);
                KisLayerSP layer = qobject_cast<KisLayer*>(d->node.data());
                layer->setChannelFlags(flags);
                break;
            }
        }

    }

>From a look into the call

    QBitArray flags = d->node->colorSpace()->channelFlags(true, true);

it appears that this does not return the current status (active/inactive) of
the layer's channels, rather it simply returns the "kind" of each channel in
the colorspace, ie. whether it is a color channel or an alpha channel.

Rather, the flags should be fetched using

    QBitArray flags = layer->channelFlags();


Modifying the code in setVisible() to read

     void Channel::setVisible(bool value)
     {
         if (!d->node || !d->channel) return;
         if (!d->node->inherits("KisLayer")) return;

    +    KisLayerSP layer = qobject_cast<KisLayer*>(d->node.data());
    +    QBitArray flags = layer->channelFlags();
    +    if (flags.isEmpty()) {
    +        flags.fill(1, d->node->colorSpace()->channelCount());
    +    }
    +
         for (uint i = 0; i < d->node->colorSpace()->channelCount(); ++i) {
             if (d->node->colorSpace()->channels()[i] == d->channel) {
    -            QBitArray flags = d->node->colorSpace()->channelFlags(true,
true);
                 flags.setBit(i, value);
    -            KisLayerSP layer = qobject_cast<KisLayer*>(d->node.data());
                 layer->setChannelFlags(flags);
                 break;
             }
         }

     }

has the desired outcome of *only* affecting the channel in question.
The python code in the original bug post now works as intended.

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to