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/ui/tool | |
| 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/ui/tool')
| -rw-r--r-- | src/ui/tool/control-point-selection.cpp | 4 | ||||
| -rw-r--r-- | src/ui/tool/control-point.cpp | 30 | ||||
| -rw-r--r-- | src/ui/tool/control-point.h | 4 | ||||
| -rw-r--r-- | src/ui/tool/event-utils.cpp | 4 | ||||
| -rw-r--r-- | src/ui/tool/multi-path-manipulator.cpp | 4 | ||||
| -rw-r--r-- | src/ui/tool/node.cpp | 16 | ||||
| -rw-r--r-- | src/ui/tool/node.h | 10 | ||||
| -rw-r--r-- | src/ui/tool/path-manipulator.cpp | 14 | ||||
| -rw-r--r-- | src/ui/tool/selectable-control-point.h | 4 | ||||
| -rw-r--r-- | src/ui/tool/selector.cpp | 2 | ||||
| -rw-r--r-- | src/ui/tool/transform-handle-set.cpp | 6 |
11 files changed, 49 insertions, 49 deletions
diff --git a/src/ui/tool/control-point-selection.cpp b/src/ui/tool/control-point-selection.cpp index a5611addc..f886c0145 100644 --- a/src/ui/tool/control-point-selection.cpp +++ b/src/ui/tool/control-point-selection.cpp @@ -179,7 +179,7 @@ void ControlPointSelection::spatialGrow(SelectableControlPoint *origin, int dir) bool grow = (dir > 0); Geom::Point p = origin->position(); double best_dist = grow ? HUGE_VAL : 0; - SelectableControlPoint *match = NULL; + SelectableControlPoint *match = nullptr; for (set_type::iterator i = _all_points.begin(); i != _all_points.end(); ++i) { bool selected = (*i)->selected(); if (grow && !selected) { @@ -423,7 +423,7 @@ void ControlPointSelection::_pointUngrabbed() _original_positions.clear(); _last_trans.clear(); _dragging = false; - _grabbed_point = _farthest_point = NULL; + _grabbed_point = _farthest_point = nullptr; _updateBounds(); restoreTransformHandles(); signal_commit.emit(COMMIT_MOUSE_MOVE); diff --git a/src/ui/tool/control-point.cpp b/src/ui/tool/control-point.cpp index 005e60c62..85475d2d5 100644 --- a/src/ui/tool/control-point.cpp +++ b/src/ui/tool/control-point.cpp @@ -42,7 +42,7 @@ ControlPoint::ColorSet ControlPoint::_default_color_set = { {0xff000000, 0x000000ff} // clicked fill, stroke when selected }; -ControlPoint *ControlPoint::mouseovered_point = 0; +ControlPoint *ControlPoint::mouseovered_point = nullptr; sigc::signal<void, ControlPoint*> ControlPoint::signal_mouseover_change; @@ -70,7 +70,7 @@ ControlPoint::ControlPoint(SPDesktop *d, Geom::Point const &initial_pos, SPAncho Glib::RefPtr<Gdk::Pixbuf> pixbuf, ColorSet const &cset, SPCanvasGroup *group) : _desktop(d), - _canvas_item(NULL), + _canvas_item(nullptr), _cset(cset), _state(STATE_NORMAL), _position(initial_pos), @@ -92,7 +92,7 @@ ControlPoint::ControlPoint(SPDesktop *d, Geom::Point const &initial_pos, SPAncho ControlType type, ColorSet const &cset, SPCanvasGroup *group) : _desktop(d), - _canvas_item(NULL), + _canvas_item(nullptr), _cset(cset), _state(STATE_NORMAL), _position(initial_pos), @@ -217,7 +217,7 @@ void ControlPoint::_setPixbuf(Glib::RefPtr<Gdk::Pixbuf> p) // re-routes events into the virtual function int ControlPoint::_event_handler(SPCanvasItem */*item*/, GdkEvent *event, ControlPoint *point) { - if ((point == NULL) || (point->_desktop == NULL)) { + if ((point == nullptr) || (point->_desktop == nullptr)) { return FALSE; } return point->_eventHandler(point->_desktop->event_context, event) ? TRUE : FALSE; @@ -229,16 +229,16 @@ bool ControlPoint::_eventHandler(Inkscape::UI::Tools::ToolBase *event_context, G // NOTE the static variables below are shared for all points! // TODO handle clicks and drags from other buttons too - if (event == NULL) + if (event == nullptr) { return false; } - if (event_context == NULL) + if (event_context == nullptr) { return false; } - if (_desktop == NULL) + if (_desktop == nullptr) { return false; } @@ -269,7 +269,7 @@ bool ControlPoint::_eventHandler(Inkscape::UI::Tools::ToolBase *event_context, G pointer_offset = _position - _desktop->w2d(_drag_event_origin); _drag_initiated = false; // route all events to this handler - sp_canvas_item_grab(_canvas_item, _grab_event_mask, NULL, event->button.time); + sp_canvas_item_grab(_canvas_item, _grab_event_mask, nullptr, event->button.time); _event_grab = true; _setState(STATE_CLICKED); return true; @@ -317,7 +317,7 @@ bool ControlPoint::_eventHandler(Inkscape::UI::Tools::ToolBase *event_context, G _desktop->scroll_to_point(new_pos); _desktop->set_coordinate_status(_position); - sp_event_context_snap_delay_handler(event_context, NULL, + sp_event_context_snap_delay_handler(event_context, nullptr, (gpointer) this, &event->motion, Inkscape::UI::Tools::DelayedSnapEvent::CONTROL_POINT_HANDLER); } @@ -370,7 +370,7 @@ bool ControlPoint::_eventHandler(Inkscape::UI::Tools::ToolBase *event_context, G case GDK_GRAB_BROKEN: if (_event_grab && !event->grab_broken.keyboard) { { - ungrabbed(NULL); + ungrabbed(nullptr); if (_drag_initiated) { _desktop->canvas->endForcedFullRedraws(); } @@ -409,10 +409,10 @@ bool ControlPoint::_eventHandler(Inkscape::UI::Tools::ToolBase *event_context, G fake.time = event->key.time; fake.x = _drag_event_origin[Geom::X]; // these two are normally not used in handlers fake.y = _drag_event_origin[Geom::Y]; // (and shouldn't be) - fake.axes = NULL; + fake.axes = nullptr; fake.state = 0; // unconstrained drag fake.is_hint = FALSE; - fake.device = NULL; + fake.device = nullptr; fake.x_root = -1; // not used in handlers (and shouldn't be) fake.y_root = -1; // can be used as a flag to check for cancelled drag @@ -424,7 +424,7 @@ bool ControlPoint::_eventHandler(Inkscape::UI::Tools::ToolBase *event_context, G _event_grab = false; _drag_initiated = false; - ungrabbed(NULL); // ungrabbed handlers can handle a NULL event + ungrabbed(nullptr); // ungrabbed handlers can handle a NULL event snapprefs.setSnapEnabledGlobally(snap_save); } return true; @@ -524,7 +524,7 @@ void ControlPoint::_clearMouseover() if (mouseovered_point) { mouseovered_point->_desktop->event_context->defaultMessageContext()->clear(); mouseovered_point->_setState(STATE_NORMAL); - mouseovered_point = 0; + mouseovered_point = nullptr; signal_mouseover_change.emit(mouseovered_point); } } @@ -535,7 +535,7 @@ void ControlPoint::transferGrab(ControlPoint *prev_point, GdkEventMotion *event) grabbed(event); sp_canvas_item_ungrab(prev_point->_canvas_item, event->time); - sp_canvas_item_grab(_canvas_item, _grab_event_mask, NULL, event->time); + sp_canvas_item_grab(_canvas_item, _grab_event_mask, nullptr, event->time); if (!_drag_initiated) { _desktop->canvas->forceFullRedrawAfterInterruptions(5); diff --git a/src/ui/tool/control-point.h b/src/ui/tool/control-point.h index 24ff86c43..2ff5b7355 100644 --- a/src/ui/tool/control-point.h +++ b/src/ui/tool/control-point.h @@ -221,7 +221,7 @@ protected: */ ControlPoint(SPDesktop *d, Geom::Point const &initial_pos, SPAnchorType anchor, ControlType type, - ColorSet const &cset = _default_color_set, SPCanvasGroup *group = 0); + ColorSet const &cset = _default_color_set, SPCanvasGroup *group = nullptr); /** * Create a control point with a pixbuf-based visual representation. @@ -235,7 +235,7 @@ protected: */ ControlPoint(SPDesktop *d, Geom::Point const &initial_pos, SPAnchorType anchor, Glib::RefPtr<Gdk::Pixbuf> pixbuf, - ColorSet const &cset = _default_color_set, SPCanvasGroup *group = 0); + ColorSet const &cset = _default_color_set, SPCanvasGroup *group = nullptr); /// @name Handle control point events in subclasses /// @{ diff --git a/src/ui/tool/event-utils.cpp b/src/ui/tool/event-utils.cpp index 7793c9d4d..99e861240 100644 --- a/src/ui/tool/event-utils.cpp +++ b/src/ui/tool/event-utils.cpp @@ -27,7 +27,7 @@ guint shortcut_key(GdkEventKey const &event) event.hardware_keycode, (GdkModifierType) event.state, 0 /*event->key.group*/, - &shortcut_key, NULL, NULL, NULL); + &shortcut_key, nullptr, nullptr, nullptr); return shortcut_key; } @@ -56,7 +56,7 @@ unsigned combine_key_events(guint keyval, gint mask) unsigned combine_motion_events(SPCanvas *canvas, GdkEventMotion &event, gint mask) { - if (canvas == NULL) { + if (canvas == nullptr) { return false; } GdkEvent *event_next; diff --git a/src/ui/tool/multi-path-manipulator.cpp b/src/ui/tool/multi-path-manipulator.cpp index b982a622f..7010f58bf 100644 --- a/src/ui/tool/multi-path-manipulator.cpp +++ b/src/ui/tool/multi-path-manipulator.cpp @@ -770,8 +770,8 @@ bool MultiPathManipulator::event(Inkscape::UI::Tools::ToolBase *event_context, G * by sub-manipulators, for example TransformHandleSet and ControlPointSelection. */ void MultiPathManipulator::_commit(CommitEvent cps) { - gchar const *reason = NULL; - gchar const *key = NULL; + gchar const *reason = nullptr; + gchar const *key = nullptr; switch(cps) { case COMMIT_MOUSE_MOVE: reason = _("Move nodes"); diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp index 94a80a882..f64ee7827 100644 --- a/src/ui/tool/node.cpp +++ b/src/ui/tool/node.cpp @@ -136,8 +136,8 @@ void Handle::move(Geom::Point const &new_pos) Handle *other = this->other(); Node *node_towards = _parent->nodeToward(this); // node in direction of this handle Node *node_away = _parent->nodeAwayFrom(this); // node in the opposite direction - Handle *towards = node_towards ? node_towards->handleAwayFrom(_parent) : NULL; - Handle *towards_second = node_towards ? node_towards->handleToward(_parent) : NULL; + Handle *towards = node_towards ? node_towards->handleAwayFrom(_parent) : nullptr; + Handle *towards_second = node_towards ? node_towards->handleToward(_parent) : nullptr; double bspline_weight = 0.0; if (Geom::are_near(new_pos, _parent->position())) { @@ -595,7 +595,7 @@ Node *Node::_next() if (n) { return n.ptr(); } else { - return NULL; + return nullptr; } } @@ -610,7 +610,7 @@ Node *Node::_prev() if (p) { return p.ptr(); } else { - return NULL; + return nullptr; } } @@ -1359,7 +1359,7 @@ Handle *Node::handleToward(Node *to) return back(); } g_error("Node::handleToward(): second node is not adjacent!"); - return NULL; + return nullptr; } Node *Node::nodeToward(Handle *dir) @@ -1371,7 +1371,7 @@ Node *Node::nodeToward(Handle *dir) return _prev(); } g_error("Node::nodeToward(): handle is not a child of this node!"); - return NULL; + return nullptr; } Handle *Node::handleAwayFrom(Node *to) @@ -1383,7 +1383,7 @@ Handle *Node::handleAwayFrom(Node *to) return front(); } g_error("Node::handleAwayFrom(): second node is not adjacent!"); - return NULL; + return nullptr; } Node *Node::nodeAwayFrom(Handle *h) @@ -1395,7 +1395,7 @@ Node *Node::nodeAwayFrom(Handle *h) return _next(); } g_error("Node::nodeAwayFrom(): handle is not a child of this node!"); - return NULL; + return nullptr; } Glib::ustring Node::_getTip(unsigned state) const diff --git a/src/ui/tool/node.h b/src/ui/tool/node.h index 6a766125a..594f6b633 100644 --- a/src/ui/tool/node.h +++ b/src/ui/tool/node.h @@ -304,16 +304,16 @@ class NodeIterator public: typedef NodeIterator self; NodeIterator() - : _node(0) + : _node(nullptr) {} // default copy, default assign self &operator++() { - _node = (_node?_node->ln_next:NULL); + _node = (_node?_node->ln_next:nullptr); return *this; } self &operator--() { - _node = (_node?_node->ln_prev:NULL); + _node = (_node?_node->ln_prev:nullptr); return *this; } bool operator==(self const &other) const { if(&other){return _node == other._node;} else{return false;} } @@ -387,9 +387,9 @@ public: bool degenerate(); void setClosed(bool c) { _closed = c; } - iterator before(double t, double *fracpart = NULL); + iterator before(double t, double *fracpart = nullptr); iterator before(Geom::PathTime const &pvp); - const_iterator before(double t, double *fracpart = NULL) const { + const_iterator before(double t, double *fracpart = nullptr) const { return const_iterator(before(t, fracpart)._node); } const_iterator before(Geom::PathTime const &pvp) const { diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index 6582501cb..5d043ffcf 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -129,7 +129,7 @@ PathManipulator::PathManipulator(MultiPathManipulator &mpm, SPPath *path, _getGeometry(); - _outline = sp_canvas_bpath_new(_multi_path_manipulator._path_data.outline_group, NULL); + _outline = sp_canvas_bpath_new(_multi_path_manipulator._path_data.outline_group, nullptr); sp_canvas_item_hide(_outline); sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(_outline), outline_color, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT); @@ -201,7 +201,7 @@ void PathManipulator::writeXML() // this manipulator will have to be destroyed right after this call _getXMLNode()->removeObserver(*_observer); _path->deleteObject(true, true); - _path = NULL; + _path = nullptr; } _observer->unblock(); } @@ -1203,7 +1203,7 @@ void PathManipulator::_createControlPointsFromGeometry() // TODO move this into SPPath - do not manipulate directly //XML Tree being used here directly while it shouldn't be. - gchar const *nts_raw = _path ? _path->getRepr()->attribute(_nodetypesKey().data()) : 0; + gchar const *nts_raw = _path ? _path->getRepr()->attribute(_nodetypesKey().data()) : nullptr; std::string nodetype_string = nts_raw ? nts_raw : ""; /* Calculate the needed length of the nodetype string. * For closed paths, the entry is duplicated for the starting node, @@ -1236,7 +1236,7 @@ void PathManipulator::_createControlPointsFromGeometry() //determines if the trace has a bspline effect and the number of steps that it takes int PathManipulator::_bsplineGetSteps() const { - LivePathEffect::LPEBSpline const *lpe_bsp = NULL; + LivePathEffect::LPEBSpline const *lpe_bsp = nullptr; SPLPEItem * path = dynamic_cast<SPLPEItem *>(_path); if (path){ @@ -1277,7 +1277,7 @@ double PathManipulator::_bsplineHandlePosition(Handle *h, bool check_other) using Geom::Y; double pos = NO_POWER; Node *n = h->parent(); - Node * next_node = NULL; + Node * next_node = nullptr; next_node = n->nodeToward(h); if(next_node){ SPCurve *line_inside_nodes = new SPCurve(); @@ -1308,7 +1308,7 @@ Geom::Point PathManipulator::_bsplineHandleReposition(Handle *h,double pos){ Node *n = h->parent(); Geom::D2< Geom::SBasis > sbasis_inside_nodes; SPCurve *line_inside_nodes = new SPCurve(); - Node * next_node = NULL; + Node * next_node = nullptr; next_node = n->nodeToward(h); if(next_node && pos != NO_POWER){ line_inside_nodes->moveto(n->position()); @@ -1482,7 +1482,7 @@ void PathManipulator::_getGeometry() _spcurve->unref(); _spcurve = _path->getCurveForEdit(); // never allow NULL to sneak in here! - if (_spcurve == NULL) { + if (_spcurve == nullptr) { _spcurve = new SPCurve(); } } diff --git a/src/ui/tool/selectable-control-point.h b/src/ui/tool/selectable-control-point.h index b3020b47f..b083516c4 100644 --- a/src/ui/tool/selectable-control-point.h +++ b/src/ui/tool/selectable-control-point.h @@ -37,12 +37,12 @@ protected: SelectableControlPoint(SPDesktop *d, Geom::Point const &initial_pos, SPAnchorType anchor, Inkscape::ControlType type, ControlPointSelection &sel, - ColorSet const &cset = _default_scp_color_set, SPCanvasGroup *group = 0); + ColorSet const &cset = _default_scp_color_set, SPCanvasGroup *group = nullptr); SelectableControlPoint(SPDesktop *d, Geom::Point const &initial_pos, SPAnchorType anchor, Glib::RefPtr<Gdk::Pixbuf> pixbuf, ControlPointSelection &sel, - ColorSet const &cset = _default_scp_color_set, SPCanvasGroup *group = 0); + ColorSet const &cset = _default_scp_color_set, SPCanvasGroup *group = nullptr); void _setState(State state) override; diff --git a/src/ui/tool/selector.cpp b/src/ui/tool/selector.cpp index 3444de809..376de399e 100644 --- a/src/ui/tool/selector.cpp +++ b/src/ui/tool/selector.cpp @@ -37,7 +37,7 @@ public: { setVisible(false); _rubber = static_cast<CtrlRect*>(sp_canvas_item_new(_desktop->getControls(), - SP_TYPE_CTRLRECT, NULL)); + SP_TYPE_CTRLRECT, nullptr)); _rubber->setShadow(1, 0xffffffff); sp_canvas_item_hide(_rubber); } diff --git a/src/ui/tool/transform-handle-set.cpp b/src/ui/tool/transform-handle-set.cpp index bb2e6c861..56c34b4d9 100644 --- a/src/ui/tool/transform-handle-set.cpp +++ b/src/ui/tool/transform-handle-set.cpp @@ -696,14 +696,14 @@ ControlPoint::ColorSet RotationCenter::_center_cset = { TransformHandleSet::TransformHandleSet(SPDesktop *d, SPCanvasGroup *th_group) : Manipulator(d) - , _active(0) + , _active(nullptr) , _transform_handle_group(th_group) , _mode(MODE_SCALE) , _in_transform(false) , _visible(true) { _trans_outline = static_cast<CtrlRect*>(sp_canvas_item_new(_desktop->getControls(), - SP_TYPE_CTRLRECT, NULL)); + SP_TYPE_CTRLRECT, nullptr)); sp_canvas_item_hide(_trans_outline); _trans_outline->setDashed(true); @@ -796,7 +796,7 @@ void TransformHandleSet::_clearActiveHandle() { // This can only be called from handles, so they had to be visible before _setActiveHandle sp_canvas_item_hide(_trans_outline); - _active = 0; + _active = nullptr; _in_transform = false; _updateVisibility(_visible); } |
