Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Canary - KryptonCustomPaletteBase --> null reference #1465

Closed
AngeloCresta opened this issue May 15, 2024 · 8 comments
Closed

[Bug]: Canary - KryptonCustomPaletteBase --> null reference #1465

AngeloCresta opened this issue May 15, 2024 · 8 comments
Labels
bug Something isn't working

Comments

@AngeloCresta
Copy link

AngeloCresta commented May 15, 2024

Hi, I have a reference null exeption in SetPalette(..) method KryptonCustomPaletteBase.cs (ln 5845 - Canary)

I suggest to modify the code initializing the basePalette if null:

   private void SetPalette(PaletteBase basePalette)
        {
            if (basePalette == null)
            {
                basePalette  = new KryptonCustomPaletteBase();
            }
            ....

Regards,
Angelo

@AngeloCresta AngeloCresta added the bug Something isn't working label May 15, 2024
@giduac
Copy link

giduac commented May 16, 2024

Hi @AngeloCresta

Which version of the toolkit are you using?
Did you try other versions, and if so was the error present as well ?
Can you please provide a simple sample project that demonstrates the error?

@AngeloCresta
Copy link
Author

AngeloCresta commented May 16, 2024

<TargetFrameworks>net8.0-windows</TargetFrameworks>

Not really, the project is huge and integrates Krypton at many levels with my other framework (ModernUI) and I've faced that error on integrating the canary version (due to all the breaking changes introduced..)

I can modify the code once is released don't worry.

Here the sample "palette designer" application behaviour with ModernUI form and theme and color with all the krypton controls styled accodingly (slow - debug)
ModernUI-KryptonIntegration

Regards,
Angelo

@giduac
Copy link

giduac commented May 16, 2024

Which Canary version of the toolkit are you using?

@AngeloCresta
Copy link
Author

I grab the version from GitHub yesterday, based on your label v90.24.4.113-beta

@giduac
Copy link

giduac commented May 16, 2024

The above video does not show anything going wrong.
The current code actually does null checking and that code is also present in the master branch. So earlier versions will act the same.

So we need some more info about how & what exactly is happening?

        private void SetPalette(PaletteBase basePalette)
        {
            if (basePalette != _basePalette)
            {
                Debug.Assert(_basePalette != null);

                // Unhook from current palette events
                if (_basePalette != null)
                {
                    _basePalette.PalettePaint -= OnPalettePaint;
                    _basePalette.ButtonSpecChanged -= OnButtonSpecChanged;
                    _basePalette.BasePaletteChanged -= OnBasePaletteChanged;
                    _basePalette.BaseRendererChanged -= OnBaseRendererChanged;
                }

                // Remember the new palette
                _basePalette = basePalette;

                // Make sure the redirector passes requests onto the base palette
                _redirector.Target = _basePalette;

                // Update the color table we inherit from
                ToolMenuStatus.BaseKCT = _basePalette.ColorTable;

                // Hook to new palette events
                if (_basePalette != null)
                {
                    _basePalette.PalettePaint += OnPalettePaint;
                    _basePalette.ButtonSpecChanged += OnButtonSpecChanged;
                    _basePalette.BasePaletteChanged += OnBasePaletteChanged;
                    _basePalette.BaseRendererChanged += OnBaseRendererChanged;
                }
            }
        }

@AngeloCresta
Copy link
Author

No, because I've added this on the method:

   private void SetPalette(PaletteBase basePalette)
        {
            if (basePalette == null)
            {
                basePalette  = new KryptonCustomPaletteBase();
            }
            ....

Commenting it out I have:

ModernUI-KryptonIntegration-Error

But, as I said, is up to you ...
Angelo

@giduac
Copy link

giduac commented May 16, 2024

I see, but: basePalette is not nullable and should be a valid param to a palette.

@AngeloCresta
Copy link
Author

Ok, I'll update my code to be sure that the custom palette is always inialized.
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants