From 15ce9a79eacd7b72637a4c6f89be03b139026902 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sun, 6 Nov 2022 19:19:33 +0100 Subject: [PATCH] Small bug fixed: color chooser button was not showing the colors from the palette --- src/layui/layui/layWidgets.cc | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/layui/layui/layWidgets.cc b/src/layui/layui/layWidgets.cc index e79b6ebcf..3d7c9100d 100644 --- a/src/layui/layui/layWidgets.cc +++ b/src/layui/layui/layWidgets.cc @@ -210,9 +210,13 @@ DitherPatternSelectionButton::update_menu () lay::DitherPattern patterns; std::string s; - lay::Dispatcher::instance ()->config_get (cfg_stipple_palette, s); - lay::StipplePalette palette; - palette.from_string (s); + if (lay::Dispatcher::instance ()) { + lay::Dispatcher::instance ()->config_get (cfg_stipple_palette, s); + } + lay::StipplePalette palette = lay::StipplePalette::default_palette (); + if (! s.empty ()) { + palette.from_string (s); + } // fill the list of stipple palette items for (unsigned int i = 0; i < palette.stipples (); ++i) { @@ -910,9 +914,13 @@ ColorButton::build_color_menu (QMenu *menu, QObject *receiver, const char *brows try { std::string s; - lay::Dispatcher::instance ()->config_get (cfg_color_palette, s); - lay::ColorPalette palette; - palette.from_string (s); + if (lay::Dispatcher::instance ()) { + lay::Dispatcher::instance ()->config_get (cfg_color_palette, s); + } + lay::ColorPalette palette = lay::ColorPalette::default_palette (); + if (! s.empty ()) { + palette.from_string (s); + } QMenu *submenu = 0;