diff options
| author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> | 2018-06-15 10:46:15 +0000 |
|---|---|---|
| committer | Marc Jeanmougin <marcjeanmougin@free.fr> | 2018-06-18 12:27:01 +0000 |
| commit | f4349fb3e45bd44cef0e2b69af4c9b4cf35dcf43 (patch) | |
| tree | 7c6044fd3a17a2665841959dac9b3b2110b27924 /src/helper | |
| parent | Run clang-tidy’s modernize-use-override pass. (diff) | |
| download | inkscape-f4349fb3e45bd44cef0e2b69af4c9b4cf35dcf43.tar.gz inkscape-f4349fb3e45bd44cef0e2b69af4c9b4cf35dcf43.zip | |
Run clang-tidy’s modernize-use-nullptr pass.
This replaces all NULL or 0 with nullptr when assigned to or returned as
a pointer.
Diffstat (limited to 'src/helper')
| -rw-r--r-- | src/helper/action-context.cpp | 12 | ||||
| -rw-r--r-- | src/helper/action.cpp | 14 | ||||
| -rw-r--r-- | src/helper/geom-pathstroke.cpp | 8 | ||||
| -rw-r--r-- | src/helper/geom.cpp | 4 | ||||
| -rw-r--r-- | src/helper/gettext.cpp | 2 | ||||
| -rw-r--r-- | src/helper/pixbuf-ops.cpp | 6 | ||||
| -rw-r--r-- | src/helper/pixbuf-ops.h | 4 | ||||
| -rw-r--r-- | src/helper/png-write.cpp | 28 | ||||
| -rw-r--r-- | src/helper/stock-items.cpp | 32 |
9 files changed, 55 insertions, 55 deletions
diff --git a/src/helper/action-context.cpp b/src/helper/action-context.cpp index 1ea12776b..e9299f7eb 100644 --- a/src/helper/action-context.cpp +++ b/src/helper/action-context.cpp @@ -18,19 +18,19 @@ namespace Inkscape { ActionContext::ActionContext() - : _selection(NULL) - , _view(NULL) + : _selection(nullptr) + , _view(nullptr) { } ActionContext::ActionContext(Selection *selection) : _selection(selection) - , _view(NULL) + , _view(nullptr) { } ActionContext::ActionContext(UI::View::View *view) - : _selection(NULL) + : _selection(nullptr) , _view(view) { SPDesktop *desktop = static_cast<SPDesktop *>(view); @@ -41,8 +41,8 @@ ActionContext::ActionContext(UI::View::View *view) SPDocument *ActionContext::getDocument() const { - if (_selection == NULL) { - return NULL; + if (_selection == nullptr) { + return nullptr; } // Should be the same as the view's document, if view is non-NULL diff --git a/src/helper/action.cpp b/src/helper/action.cpp index 48e051ada..6e44487f9 100644 --- a/src/helper/action.cpp +++ b/src/helper/action.cpp @@ -45,8 +45,8 @@ sp_action_init (SPAction *action) action->sensitive = 0; action->active = 0; action->context = Inkscape::ActionContext(); - action->id = action->name = action->tip = NULL; - action->image = NULL; + action->id = action->name = action->tip = nullptr; + action->image = nullptr; new (&action->signal_perform) sigc::signal<void>(); new (&action->signal_set_sensitive) sigc::signal<void, bool>(); @@ -86,7 +86,7 @@ sp_action_new(Inkscape::ActionContext const &context, const gchar *image, Inkscape::Verb * verb) { - SPAction *action = (SPAction *)g_object_new(SP_TYPE_ACTION, NULL); + SPAction *action = (SPAction *)g_object_new(SP_TYPE_ACTION, nullptr); action->context = context; action->sensitive = TRUE; @@ -131,7 +131,7 @@ public: */ void sp_action_perform(SPAction *action, void * /*data*/) { - g_return_if_fail (action != NULL); + g_return_if_fail (action != nullptr); g_return_if_fail (SP_IS_ACTION (action)); Inkscape::Debug::EventTracker<ActionEvent> tracker(action); @@ -144,7 +144,7 @@ void sp_action_perform(SPAction *action, void * /*data*/) void sp_action_set_active (SPAction *action, unsigned int active) { - g_return_if_fail (action != NULL); + g_return_if_fail (action != nullptr); g_return_if_fail (SP_IS_ACTION (action)); action->signal_set_active.emit(active); @@ -156,7 +156,7 @@ sp_action_set_active (SPAction *action, unsigned int active) void sp_action_set_sensitive (SPAction *action, unsigned int sensitive) { - g_return_if_fail (action != NULL); + g_return_if_fail (action != nullptr); g_return_if_fail (SP_IS_ACTION (action)); action->signal_set_sensitive.emit(sensitive); @@ -165,7 +165,7 @@ sp_action_set_sensitive (SPAction *action, unsigned int sensitive) void sp_action_set_name (SPAction *action, Glib::ustring const &name) { - g_return_if_fail (action != NULL); + g_return_if_fail (action != nullptr); g_return_if_fail (SP_IS_ACTION (action)); g_free(action->name); diff --git a/src/helper/geom-pathstroke.cpp b/src/helper/geom-pathstroke.cpp index c3e4f8213..b9cc1a38f 100644 --- a/src/helper/geom-pathstroke.cpp +++ b/src/helper/geom-pathstroke.cpp @@ -401,10 +401,10 @@ void extrapolate_join_internal(join_data jd, int alternative) std::vector<Geom::ShapeIntersection> points; - Geom::EllipticalArc *arc1 = NULL; - Geom::EllipticalArc *arc2 = NULL; - Geom::LineSegment *seg1 = NULL; - Geom::LineSegment *seg2 = NULL; + Geom::EllipticalArc *arc1 = nullptr; + Geom::EllipticalArc *arc2 = nullptr; + Geom::LineSegment *seg1 = nullptr; + Geom::LineSegment *seg2 = nullptr; Geom::Point sol; Geom::Point p1; Geom::Point p2; diff --git a/src/helper/geom.cpp b/src/helper/geom.cpp index 6bdf911e5..e83fb42f2 100644 --- a/src/helper/geom.cpp +++ b/src/helper/geom.cpp @@ -330,8 +330,8 @@ geom_cubic_bbox_wind_distance (Geom::Coord x000, Geom::Coord y000, y1tt = s * y01t + t * y11t; yttt = s * y0tt + t * y1tt; - geom_cubic_bbox_wind_distance (x000, y000, x00t, y00t, x0tt, y0tt, xttt, yttt, pt, NULL, wind, best, tolerance); - geom_cubic_bbox_wind_distance (xttt, yttt, x1tt, y1tt, x11t, y11t, x111, y111, pt, NULL, wind, best, tolerance); + geom_cubic_bbox_wind_distance (x000, y000, x00t, y00t, x0tt, y0tt, xttt, yttt, pt, nullptr, wind, best, tolerance); + geom_cubic_bbox_wind_distance (xttt, yttt, x1tt, y1tt, x11t, y11t, x111, y111, pt, nullptr, wind, best, tolerance); } else { geom_line_wind_distance (x000, y000, x111, y111, pt, wind, best); } diff --git a/src/helper/gettext.cpp b/src/helper/gettext.cpp index 1942b373c..226304267 100644 --- a/src/helper/gettext.cpp +++ b/src/helper/gettext.cpp @@ -68,7 +68,7 @@ void initialize_gettext() { // Allow the user to override the locale directory by setting // the environment variable INKSCAPE_LOCALEDIR. char const *inkscape_localedir = g_getenv("INKSCAPE_LOCALEDIR"); - if (inkscape_localedir != NULL) { + if (inkscape_localedir != nullptr) { bindtextdomain(GETTEXT_PACKAGE, inkscape_localedir); } diff --git a/src/helper/pixbuf-ops.cpp b/src/helper/pixbuf-ops.cpp index 3b43735ad..947af3b50 100644 --- a/src/helper/pixbuf-ops.cpp +++ b/src/helper/pixbuf-ops.cpp @@ -73,7 +73,7 @@ bool sp_export_jpg_file(SPDocument *doc, gchar const *filename, gchar c[32]; g_snprintf(c, 32, "%f", quality); - gboolean saved = gdk_pixbuf_save(pixbuf->getPixbufRaw(), filename, "jpeg", NULL, "quality", c, NULL); + gboolean saved = gdk_pixbuf_save(pixbuf->getPixbufRaw(), filename, "jpeg", nullptr, "quality", c, NULL); return saved; } @@ -99,9 +99,9 @@ Inkscape::Pixbuf *sp_generate_internal_bitmap(SPDocument *doc, gchar const */*fi SPItem *item_only) { - if (width == 0 || height == 0) return NULL; + if (width == 0 || height == 0) return nullptr; - Inkscape::Pixbuf *inkpb = NULL; + Inkscape::Pixbuf *inkpb = nullptr; /* Create new drawing for offscreen rendering*/ Inkscape::Drawing drawing; drawing.setExact(true); diff --git a/src/helper/pixbuf-ops.h b/src/helper/pixbuf-ops.h index 067bc0be4..6f326a286 100644 --- a/src/helper/pixbuf-ops.h +++ b/src/helper/pixbuf-ops.h @@ -18,11 +18,11 @@ class SPDocument; namespace Inkscape { class Pixbuf; } bool sp_export_jpg_file (SPDocument *doc, gchar const *filename, double x0, double y0, double x1, double y1, - unsigned int width, unsigned int height, double xdpi, double ydpi, unsigned long bgcolor, double quality, SPItem *item_only = NULL); + unsigned int width, unsigned int height, double xdpi, double ydpi, unsigned long bgcolor, double quality, SPItem *item_only = nullptr); Inkscape::Pixbuf *sp_generate_internal_bitmap(SPDocument *doc, gchar const *filename, double x0, double y0, double x1, double y1, unsigned width, unsigned height, double xdpi, double ydpi, - unsigned long bgcolor, SPItem *item_only = NULL); + unsigned long bgcolor, SPItem *item_only = nullptr); #endif diff --git a/src/helper/png-write.cpp b/src/helper/png-write.cpp index 93b07d410..a66d683ac 100644 --- a/src/helper/png-write.cpp +++ b/src/helper/png-write.cpp @@ -70,7 +70,7 @@ typedef struct SPPNGBD { */ class PngTextList { public: - PngTextList() : count(0), textItems(0) {} + PngTextList() : count(0), textItems(nullptr) {} ~PngTextList(); void add(gchar const* key, gchar const* text); @@ -97,7 +97,7 @@ void PngTextList::add(gchar const* key, gchar const* text) { if (count < 0) { count = 0; - textItems = 0; + textItems = nullptr; } png_text* tmp = (count > 0) ? g_try_renew(png_text, textItems, count + 1): g_try_new(png_text, 1); if (tmp) { @@ -111,12 +111,12 @@ void PngTextList::add(gchar const* key, gchar const* text) item->text_length = 0; #ifdef PNG_iTXt_SUPPORTED item->itxt_length = 0; - item->lang = 0; - item->lang_key = 0; + item->lang = nullptr; + item->lang_key = nullptr; #endif // PNG_iTXt_SUPPORTED } else { g_warning("Unable to allocate arrary for %d PNG text data.", count); - textItems = 0; + textItems = nullptr; count = 0; } } @@ -127,8 +127,8 @@ sp_png_write_rgba_striped(SPDocument *doc, int (* get_rows)(guchar const **rows, void **to_free, int row, int num_rows, void *data, int color_type, int bit_depth, int antialias), void *data, bool interlace, int color_type, int bit_depth, int zlib, int antialiasing) { - g_return_val_if_fail(filename != NULL, false); - g_return_val_if_fail(data != NULL, false); + g_return_val_if_fail(filename != nullptr, false); + g_return_val_if_fail(data != nullptr, false); struct SPEBP *ebp = (struct SPEBP *) data; FILE *fp; @@ -141,7 +141,7 @@ sp_png_write_rgba_striped(SPDocument *doc, Inkscape::IO::dump_fopen_call(filename, "M"); fp = Inkscape::IO::fopen_utf8name(filename, "wb"); - if(fp == NULL) return false; + if(fp == nullptr) return false; /* Create and initialize the png_struct with the desired error handler * functions. If you want to use the default stderr and longjump method, @@ -149,18 +149,18 @@ sp_png_write_rgba_striped(SPDocument *doc, * the library version is compatible with the one used at compile time, * in case we are using dynamically linked libraries. REQUIRED. */ - png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); + png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, nullptr, nullptr, nullptr); - if (png_ptr == NULL) { + if (png_ptr == nullptr) { fclose(fp); return false; } /* Allocate/initialize the image information data. REQUIRED */ info_ptr = png_create_info_struct(png_ptr); - if (info_ptr == NULL) { + if (info_ptr == nullptr) { fclose(fp); - png_destroy_write_struct(&png_ptr, NULL); + png_destroy_write_struct(&png_ptr, nullptr); return false; } @@ -411,8 +411,8 @@ ExportResult sp_export_png_file(SPDocument *doc, gchar const *filename, void *data, bool force_overwrite, const std::vector<SPItem*> &items_only, bool interlace, int color_type, int bit_depth, int zlib, int antialiasing) { - g_return_val_if_fail(doc != NULL, EXPORT_ERROR); - g_return_val_if_fail(filename != NULL, EXPORT_ERROR); + g_return_val_if_fail(doc != nullptr, EXPORT_ERROR); + g_return_val_if_fail(filename != nullptr, EXPORT_ERROR); g_return_val_if_fail(width >= 1, EXPORT_ERROR); g_return_val_if_fail(height >= 1, EXPORT_ERROR); g_return_val_if_fail(!area.hasZeroArea(), EXPORT_ERROR); diff --git a/src/helper/stock-items.cpp b/src/helper/stock-items.cpp index d33186344..75dd957c5 100644 --- a/src/helper/stock-items.cpp +++ b/src/helper/stock-items.cpp @@ -49,10 +49,10 @@ static SPObject *sp_gradient_load_from_svg(gchar const *name, SPDocument *curren static SPObject * sp_marker_load_from_svg(gchar const *name, SPDocument *current_doc) { - static SPDocument *doc = NULL; + static SPDocument *doc = nullptr; static unsigned int edoc = FALSE; if (!current_doc) { - return NULL; + return nullptr; } /* Try to load from document */ if (!edoc && !doc) { @@ -74,23 +74,23 @@ static SPObject * sp_marker_load_from_svg(gchar const *name, SPDocument *current SPDefs *defs = current_doc->getDefs(); Inkscape::XML::Document *xml_doc = current_doc->getReprDoc(); Inkscape::XML::Node *mark_repr = object->getRepr()->duplicate(xml_doc); - defs->getRepr()->addChild(mark_repr, NULL); + defs->getRepr()->addChild(mark_repr, nullptr); SPObject *cloned_item = current_doc->getObjectByRepr(mark_repr); Inkscape::GC::release(mark_repr); return cloned_item; } } - return NULL; + return nullptr; } static SPObject * sp_pattern_load_from_svg(gchar const *name, SPDocument *current_doc) { - static SPDocument *doc = NULL; + static SPDocument *doc = nullptr; static unsigned int edoc = FALSE; if (!current_doc) { - return NULL; + return nullptr; } /* Try to load from document */ if (!edoc && !doc) { @@ -118,22 +118,22 @@ sp_pattern_load_from_svg(gchar const *name, SPDocument *current_doc) SPDefs *defs = current_doc->getDefs(); Inkscape::XML::Document *xml_doc = current_doc->getReprDoc(); Inkscape::XML::Node *pat_repr = object->getRepr()->duplicate(xml_doc); - defs->getRepr()->addChild(pat_repr, NULL); + defs->getRepr()->addChild(pat_repr, nullptr); Inkscape::GC::release(pat_repr); return object; } } - return NULL; + return nullptr; } static SPObject * sp_gradient_load_from_svg(gchar const *name, SPDocument *current_doc) { - static SPDocument *doc = NULL; + static SPDocument *doc = nullptr; static unsigned int edoc = FALSE; if (!current_doc) { - return NULL; + return nullptr; } /* Try to load from document */ if (!edoc && !doc) { @@ -161,12 +161,12 @@ sp_gradient_load_from_svg(gchar const *name, SPDocument *current_doc) SPDefs *defs = current_doc->getDefs(); Inkscape::XML::Document *xml_doc = current_doc->getReprDoc(); Inkscape::XML::Node *pat_repr = object->getRepr()->duplicate(xml_doc); - defs->getRepr()->addChild(pat_repr, NULL); + defs->getRepr()->addChild(pat_repr, nullptr); Inkscape::GC::release(pat_repr); return object; } } - return NULL; + return nullptr; } // get_stock_item returns a pointer to an instance of the desired stock object in the current doc @@ -175,7 +175,7 @@ sp_gradient_load_from_svg(gchar const *name, SPDocument *current_doc) SPObject *get_stock_item(gchar const *urn, gboolean stock) { - g_assert(urn != NULL); + g_assert(urn != nullptr); /* check its an inkscape URN */ if (!strncmp (urn, "urn:inkscape:", 13)) { @@ -200,9 +200,9 @@ SPObject *get_stock_item(gchar const *urn, gboolean stock) SPDefs *defs = doc->getDefs(); if (!defs) { g_free(base); - return NULL; + return nullptr; } - SPObject *object = NULL; + SPObject *object = nullptr; if (!strcmp(base, "marker") && !stock) { for (auto& child: defs->children) { @@ -240,7 +240,7 @@ SPObject *get_stock_item(gchar const *urn, gboolean stock) } - if (object == NULL) { + if (object == nullptr) { if (!strcmp(base, "marker")) { object = sp_marker_load_from_svg(name_p, doc); |
