X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FColorHandler.C;h=416f09fea706e055c519c15c4c972f29d4faa818;hb=77866d9e88cbbd1f5f580a7daf15751352792e12;hp=c6f6fba32a0f27ad19672a88b658f19961c745a1;hpb=bae1cc9a9d1e58ca5284ccdc632be9c0675cd72a;p=lyx.git diff --git a/src/ColorHandler.C b/src/ColorHandler.C index c6f6fba32a..416f09fea7 100644 --- a/src/ColorHandler.C +++ b/src/ColorHandler.C @@ -86,7 +86,7 @@ GC LyXColorHandler::getGCForeground(LColor::color c) if (XLookupColor(display, colormap, s.c_str(), &xcol, &ccol) == 0) { lyxerr << _("LyX: Unknown X11 color ") << s << _(" for ") << lcolor.getGUIName(c) << '\n' - << _(" Using black instead, sorry!.") << endl; + << _(" Using black instead, sorry!") << endl; unsigned long bla = BlackPixel(display, DefaultScreen(display)); val.foreground = bla; @@ -108,12 +108,12 @@ GC LyXColorHandler::getGCForeground(LColor::color c) // the color closest to the one we want. Visual * vi = DefaultVisual(display, DefaultScreen(display)); - XColor * cmap = new XColor[vi->map_entries]; + boost::scoped_array cmap(new XColor[vi->map_entries]); for (int i = 0; i < vi->map_entries; ++i) { cmap[i].pixel = i; } - XQueryColors(display, colormap, cmap, vi->map_entries); + XQueryColors(display, colormap, cmap.get(), vi->map_entries); // Walk through the cmap and look for close colors. int closest_pixel = 0; @@ -153,7 +153,6 @@ GC LyXColorHandler::getGCForeground(LColor::color c) << _("Pixel [") << closest_pixel << _("] is used.") << endl; val.foreground = cmap[closest_pixel].pixel; - delete[] cmap; } val.function = GXcopy; @@ -172,8 +171,9 @@ GC LyXColorHandler::getGCLinepars(PainterBase::line_style ls, int index = lw + (ls << 1) + (c << 6); - if (lineGCcache.find(index) != lineGCcache.end()) - return lineGCcache[index]; + LineGCCache::iterator it = lineGCcache.find(index); + if (it != lineGCcache.end()) + return it->second; XGCValues val; XGetGCValues(display, getGCForeground(c), GCForeground, &val); @@ -227,10 +227,11 @@ void LyXColorHandler::updateColor (LColor::color c) for (int ls = 0; ls < 3; ++ls) for (int lw = 0; lw < 2; ++lw) { int const index = lw + (ls << 1) + (c << 6); - if (lineGCcache.find(index) != lineGCcache.end()) { - gc = lineGCcache[index]; - XFreeGC(display,gc); - lineGCcache.erase(index); + LineGCCache::iterator it = lineGCcache.find(index); + if (it != lineGCcache.end()) { + gc = it->second; + XFreeGC(display, gc); + lineGCcache.erase(it); getGCLinepars(PainterBase::line_style(ls), PainterBase::line_width(lw), c); }