chart2/source/controller/sidebar/ChartColorsPanel.cxx |   26 +++++++++++++++---
 1 file changed, 22 insertions(+), 4 deletions(-)

New commits:
commit de9093a10c0f805378bc5036c355e671cf1efcde
Author:     Marco Cecchetti <marco.cecche...@collabora.com>
AuthorDate: Tue May 20 14:41:48 2025 +0200
Commit:     Marco Cecchetti <marco.cecche...@collabora.com>
CommitDate: Thu May 22 18:29:06 2025 +0200

    chart color palette: assertion failure in getCID
    
    Change-Id: I5e5628abb4e7e23ccc0f884c8ccb17167a368f39
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185557
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Tomaž Vajngerl <qui...@gmail.com>
    (cherry picked from commit f99bc3659663164b0e1d36452f2935ac98324893)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185655
    Reviewed-by: Marco Cecchetti <marco.cecche...@collabora.com>
    Tested-by: Jenkins

diff --git a/chart2/source/controller/sidebar/ChartColorsPanel.cxx 
b/chart2/source/controller/sidebar/ChartColorsPanel.cxx
index 33ee82fb812a..259365a28adb 100644
--- a/chart2/source/controller/sidebar/ChartColorsPanel.cxx
+++ b/chart2/source/controller/sidebar/ChartColorsPanel.cxx
@@ -44,12 +44,28 @@ namespace
 OUString getCID(const uno::Reference<frame::XModel>& xModel)
 {
     const uno::Reference<frame::XController> 
xController(xModel->getCurrentController());
-    const uno::Reference<view::XSelectionSupplier> 
xSelectionSupplier(xController, uno::UNO_QUERY);
+    uno::Reference<view::XSelectionSupplier> xSelectionSupplier(xController, 
uno::UNO_QUERY);
     if (!xSelectionSupplier.is())
-        return OUString();
+        return {};
+
+    uno::Any aAny = xSelectionSupplier->getSelection();
+    if (!aAny.hasValue())
+    {
+        // if no selection, default to diagram wall so sidebar can show some 
editable properties
+        if (auto* pController = 
dynamic_cast<ChartController*>(xController.get()))
+        {
+            pController->select(
+                
uno::Any(ObjectIdentifier::createClassifiedIdentifier(OBJECTTYPE_PAGE, u"")));
+            xSelectionSupplier
+                = uno::Reference<css::view::XSelectionSupplier>(xController, 
uno::UNO_QUERY);
+            if (xSelectionSupplier.is())
+                aAny = xSelectionSupplier->getSelection();
+        }
+
+        if (!aAny.hasValue())
+            return {};
+    }
 
-    const uno::Any aAny = xSelectionSupplier->getSelection();
-    assert(aAny.hasValue());
     OUString aCID;
     aAny >>= aCID;
     return aCID;
@@ -183,6 +199,8 @@ void ChartColorsPanel::updateData()
         return;
 
     const OUString aCID = getCID(mxModel);
+    if (aCID.isEmpty())
+        return;
     const ObjectType eType = ObjectIdentifier::getObjectType(aCID);
 
     if (std::find(maAcceptedTypes.begin(), maAcceptedTypes.end(), eType) == 
maAcceptedTypes.end())

Reply via email to