Skip to content

Commit

Permalink
Specify the types of unique_ptr deleters with std::function
Browse files Browse the repository at this point in the history
Other developers (including myself) don't really care either way, but
@Vultraz prefers std::function over C-style function pointer types.
  • Loading branch information
jyrkive committed May 7, 2017
1 parent d20e989 commit f2d4bcb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/font/text.cpp
Expand Up @@ -159,7 +159,7 @@ gui2::point pango_text::get_cursor_position(

// First we need to determine the byte offset, if more routines need it it
// would be a good idea to make it a separate function.
std::unique_ptr<PangoLayoutIter, void(*)(PangoLayoutIter*)> itor(
std::unique_ptr<PangoLayoutIter, std::function<void(PangoLayoutIter*)>> itor(
pango_layout_get_iter(layout_.get()), pango_layout_iter_free);

// Go the wanted line.
Expand Down Expand Up @@ -646,9 +646,9 @@ void pango_text::render(PangoLayout& layout, const PangoRectangle& rect, const s
cairo_format_t format = CAIRO_FORMAT_ARGB32;

unsigned char* buffer = &surface_buffer_[surface_buffer_offset];
std::unique_ptr<cairo_surface_t, void(*)(cairo_surface_t*)> cairo_surface(
std::unique_ptr<cairo_surface_t, std::function<void(cairo_surface_t*)>> cairo_surface(
cairo_image_surface_create_for_data(buffer, format, width, height, stride), cairo_surface_destroy);
std::unique_ptr<cairo_t, void(*)(cairo_t*)> cr(cairo_create(cairo_surface.get()), cairo_destroy);
std::unique_ptr<cairo_t, std::function<void(cairo_t*)>> cr(cairo_create(cairo_surface.get()), cairo_destroy);

if(cairo_status(cr.get()) == CAIRO_STATUS_INVALID_SIZE) {
if(!is_surface_split()) {
Expand Down
6 changes: 3 additions & 3 deletions src/font/text.hpp
Expand Up @@ -248,12 +248,12 @@ class pango_text
private:

/***** ***** ***** ***** Pango variables ***** ***** ***** *****/
std::unique_ptr<PangoContext, void(*)(void*)> context_;
std::unique_ptr<PangoLayout, void(*)(void*)> layout_;
std::unique_ptr<PangoContext, std::function<void(void*)>> context_;
std::unique_ptr<PangoLayout, std::function<void(void*)>> layout_;
mutable PangoRectangle rect_;

// Used if the text is too long to fit into a single Cairo surface.
std::vector<std::unique_ptr<PangoLayout, void(*)(void*)>> sublayouts_;
std::vector<std::unique_ptr<PangoLayout, std::function<void(void*)>>> sublayouts_;

/** The SDL surface to render upon used as a cache. */
mutable surface surface_;
Expand Down

0 comments on commit f2d4bcb

Please sign in to comment.