[niepce] Check that we have a valid label index before asserting.



commit 299c4e26915251c455712f3131b4564e979e665d
Author: Hub Figuiere <hub figuiere net>
Date:   Sun Nov 6 13:37:11 2011 -0800

    Check that we have a valid label index before asserting.

 src/niepce/ui/librarycellrenderer.cpp |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)
---
diff --git a/src/niepce/ui/librarycellrenderer.cpp b/src/niepce/ui/librarycellrenderer.cpp
index 0f0b104..002d283 100644
--- a/src/niepce/ui/librarycellrenderer.cpp
+++ b/src/niepce/ui/librarycellrenderer.cpp
@@ -288,11 +288,13 @@ LibraryCellRenderer::render_vfunc(const Glib::RefPtr<Gdk::Drawable>& window,
         int left = drawFormatEmblem(cr, emblem, r);
         if(m_drawlabel) {
             DBG_ASSERT(m_uiDataProvider, "no UIDataProvider");
-            uint32_t label_index = file->label();
-            const fwk::RgbColor * label_color = m_uiDataProvider->colorForLabel(label_index);
-            DBG_ASSERT(label_color, "color not found");
-            if(label_color) {
-                drawLabel(cr, left, label_color, r);
+            uint32_t label_id = file->label();
+            if(label_id != 0) {
+                const fwk::RgbColor * label_color = m_uiDataProvider->colorForLabel(label_id);
+                DBG_ASSERT(label_color, "color not found");
+                if(label_color) {
+                    drawLabel(cr, left, label_color, r);
+                }
             }
         }
     }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]