diff options
| author | Jabier Arraiza Cenoz <jabier.arraiza@marker.es> | 2013-10-18 16:44:48 +0000 |
|---|---|---|
| committer | Jabiertxof <jtx@jtx.marker.es> | 2013-10-18 16:44:48 +0000 |
| commit | c6f1fa0dfb5beaac7b0781213711028b511c5f6e (patch) | |
| tree | 3712e7c481f312bde6cb19d9b760ad0ba6f48f2a /src | |
| parent | Update to trunk (diff) | |
| parent | fix memory reallocation (diff) | |
| download | inkscape-c6f1fa0dfb5beaac7b0781213711028b511c5f6e.tar.gz inkscape-c6f1fa0dfb5beaac7b0781213711028b511c5f6e.zip | |
Update to trunk
(bzr r11950.1.185)
Diffstat (limited to 'src')
| -rw-r--r-- | src/color-profile.cpp | 38 | ||||
| -rw-r--r-- | src/desktop.cpp | 2 | ||||
| -rw-r--r-- | src/flood-context.cpp | 2 | ||||
| -rw-r--r-- | src/gradient-drag.cpp | 2 | ||||
| -rw-r--r-- | src/libcola/cola.cpp | 12 | ||||
| -rw-r--r-- | src/libcola/gradient_projection.h | 23 | ||||
| -rw-r--r-- | src/libcola/straightener.cpp | 2 | ||||
| -rw-r--r-- | src/libcola/straightener.h | 4 | ||||
| -rw-r--r-- | src/libnrtype/TextWrapper.cpp | 84 | ||||
| -rw-r--r-- | src/libuemf/uemf.c | 2 | ||||
| -rw-r--r-- | src/libuemf/uemf_print.c | 2 | ||||
| -rw-r--r-- | src/libvpsc/constraint.cpp | 4 | ||||
| -rw-r--r-- | src/livarot/PathOutline.cpp | 4 | ||||
| -rw-r--r-- | src/livarot/Shape.cpp | 4 | ||||
| -rw-r--r-- | src/seltrans.cpp | 2 | ||||
| -rw-r--r-- | src/xml/repr-io.cpp | 11 |
16 files changed, 153 insertions, 45 deletions
diff --git a/src/color-profile.cpp b/src/color-profile.cpp index f0a06f73b..b18112ece 100644 --- a/src/color-profile.cpp +++ b/src/color-profile.cpp @@ -1165,13 +1165,24 @@ cmsHTRANSFORM Inkscape::CMSSystem::getDisplayTransform() cmsUInt32Number dwFlags = cmsFLAGS_SOFTPROOFING; if ( gamutWarn ) { dwFlags |= cmsFLAGS_GAMUTCHECK; + +#if WITH_GTKMM_3_0 + gushort gamutColor_r = gamutColor.get_red_u(); + gushort gamutColor_g = gamutColor.get_green_u(); + gushort gamutColor_b = gamutColor.get_blue_u(); +#else + gushort gamutColor_r = gamutColor.get_red(); + gushort gamutColor_g = gamutColor.get_green(); + gushort gamutColor_b = gamutColor.get_blue(); +#endif + #if HAVE_LIBLCMS1 - cmsSetAlarmCodes(gamutColor.get_red() >> 8, gamutColor.get_green() >> 8, gamutColor.get_blue() >> 8); + cmsSetAlarmCodes(gamutColor_r >> 8, gamutColor_g >> 8, gamutColor_b >> 8); #elif HAVE_LIBLCMS2 cmsUInt16Number newAlarmCodes[cmsMAXCHANNELS] = {0}; - newAlarmCodes[0] = gamutColor.get_red(); - newAlarmCodes[1] = gamutColor.get_green(); - newAlarmCodes[2] = gamutColor.get_blue(); + newAlarmCodes[0] = gamutColor_r; + newAlarmCodes[1] = gamutColor_g; + newAlarmCodes[2] = gamutColor_b; newAlarmCodes[3] = ~0; cmsSetAlarmCodes(newAlarmCodes); #endif @@ -1339,13 +1350,24 @@ cmsHTRANSFORM Inkscape::CMSSystem::getDisplayPer( Glib::ustring const& id ) cmsUInt32Number dwFlags = cmsFLAGS_SOFTPROOFING; if ( gamutWarn ) { dwFlags |= cmsFLAGS_GAMUTCHECK; + +#if WITH_GTKMM_3_0 + gushort gamutColor_r = gamutColor.get_red_u(); + gushort gamutColor_g = gamutColor.get_green_u(); + gushort gamutColor_b = gamutColor.get_blue_u(); +#else + gushort gamutColor_r = gamutColor.get_red(); + gushort gamutColor_g = gamutColor.get_green(); + gushort gamutColor_b = gamutColor.get_blue(); +#endif + #if HAVE_LIBLCMS1 - cmsSetAlarmCodes(gamutColor.get_red() >> 8, gamutColor.get_green() >> 8, gamutColor.get_blue() >> 8); + cmsSetAlarmCodes(gamutColor_r >> 8, gamutColor_g >> 8, gamutColor_b >> 8); #elif HAVE_LIBLCMS2 cmsUInt16Number newAlarmCodes[cmsMAXCHANNELS] = {0}; - newAlarmCodes[0] = gamutColor.get_red(); - newAlarmCodes[1] = gamutColor.get_green(); - newAlarmCodes[2] = gamutColor.get_blue(); + newAlarmCodes[0] = gamutColor_r; + newAlarmCodes[1] = gamutColor_g; + newAlarmCodes[2] = gamutColor_b; newAlarmCodes[3] = ~0; cmsSetAlarmCodes(newAlarmCodes); #endif diff --git a/src/desktop.cpp b/src/desktop.cpp index dbad37b92..f5c35514c 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -1930,7 +1930,7 @@ SPDesktop::show_dialogs() mapVerbPreference.insert(std::make_pair ("SpellCheck", "/dialogs/spellcheck") ); mapVerbPreference.insert(std::make_pair ("Symbols", "/dialogs/symbols") ); - for (std::map<Glib::ustring, Glib::ustring>::const_iterator iter = mapVerbPreference.begin(); iter != mapVerbPreference.end(); iter++) { + for (std::map<Glib::ustring, Glib::ustring>::const_iterator iter = mapVerbPreference.begin(); iter != mapVerbPreference.end(); ++iter) { Glib::ustring pref = iter->second; int visible = prefs->getInt(pref + "/visible", 0); if (visible) { diff --git a/src/flood-context.cpp b/src/flood-context.cpp index 28aedba6e..dc89fb0a9 100644 --- a/src/flood-context.cpp +++ b/src/flood-context.cpp @@ -955,7 +955,7 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even unsigned int sort_y = (unsigned int)cp[Geom::Y]; unsigned int current_y = sort_y; - for (std::deque<Geom::Point>::iterator i = fill_queue.begin(); i != fill_queue.end(); i++) { + for (std::deque<Geom::Point>::iterator i = fill_queue.begin(); i != fill_queue.end(); ++i) { Geom::Point current = *i; current_y = (unsigned int)current[Geom::Y]; if (current_y != sort_y) { diff --git a/src/gradient-drag.cpp b/src/gradient-drag.cpp index b3622107b..0b250fe52 100644 --- a/src/gradient-drag.cpp +++ b/src/gradient-drag.cpp @@ -879,7 +879,7 @@ static void gr_knot_moved_handler(SPKnot *knot, Geom::Point const &ppointer, gui if (!bsp.getSnapped()) { // If we didn't truly snap to an object or to a grid, then we will still have to look for the // closest projection onto one of the constraints. findBestSnap() will not do this for us - for (std::list<Inkscape::SnappedPoint>::const_iterator i = isr.points.begin(); i != isr.points.end(); i++) { + for (std::list<Inkscape::SnappedPoint>::const_iterator i = isr.points.begin(); i != isr.points.end(); ++i) { if (i == isr.points.begin() || (Geom::L2((*i).getPoint() - p) < Geom::L2(bsp.getPoint() - p))) { bsp.setPoint((*i).getPoint()); bsp.setTarget(Inkscape::SNAPTARGET_CONSTRAINED_ANGLE); diff --git a/src/libcola/cola.cpp b/src/libcola/cola.cpp index 87fbf9f79..168ef5533 100644 --- a/src/libcola/cola.cpp +++ b/src/libcola/cola.cpp @@ -23,7 +23,8 @@ ConstrainedMajorizationLayout double* eweights, double idealLength, TestConvergence& done) - : constrainedLayout(false), + : avoidOverlaps(false), + constrainedLayout(false), n(rs.size()), lapSize(n), lap2(new double*[lapSize]), Q(lap2), Dij(new double*[lapSize]), @@ -116,18 +117,17 @@ void ConstrainedMajorizationLayout::majlayout( void ConstrainedMajorizationLayout::majlayout( double** Dij, GradientProjection* gp, double* coords, double* b) { - double L_ij,dist_ij,degree; /* compute the vector b */ /* multiply on-the-fly with distance-based laplacian */ for (unsigned i = 0; i < n; i++) { - degree = 0; if(i<lapSize) { + double degree = 0; for (unsigned j = 0; j < lapSize; j++) { if (j == i) continue; - dist_ij = euclidean_distance(i, j); + double dist_ij = euclidean_distance(i, j); if (dist_ij > 1e-30 && Dij[i][j] > 1e-30) { /* skip zero distances */ /* calculate L_ij := w_{ij}*d_{ij}/dist_{ij} */ - L_ij = 1.0 / (dist_ij * Dij[i][j]); + double L_ij = 1.0 / (dist_ij * Dij[i][j]); degree -= L_ij; b[i] += L_ij * coords[j]; } @@ -271,7 +271,7 @@ void ConstrainedMajorizationLayout::straighten(std::vector<straightener::Edge*>& double b[n],*coords=dim==HORIZONTAL?X:Y,dist_ub,dist_bv; std::fill(b,b+n,0); for(LinearConstraints::iterator i=linearConstraints.begin(); - i!= linearConstraints.end();i++) { + i!= linearConstraints.end();++i) { LinearConstraint* c=*i; if(straightenToProjection) { Q[c->u][c->u]+=c->w*c->duu; diff --git a/src/libcola/gradient_projection.h b/src/libcola/gradient_projection.h index 8cf45586c..980fa6064 100644 --- a/src/libcola/gradient_projection.h +++ b/src/libcola/gradient_projection.h @@ -25,7 +25,12 @@ typedef std::vector<SimpleConstraint*> SimpleConstraints; class AlignmentConstraint { friend class GradientProjection; public: - AlignmentConstraint(double pos) : position(pos), variable(NULL) {} + AlignmentConstraint(double pos) : + offsets(), + guide(NULL), + position(pos), + variable(NULL) + {} void updatePosition() { position = variable->position(); } @@ -74,7 +79,21 @@ typedef std::vector<std::pair<unsigned, double> > CList; */ class DummyVarPair { public: - DummyVarPair(double desiredDist) : dist(desiredDist), lap2(1.0/(desiredDist*desiredDist)) { } + DummyVarPair(double desiredDist) : + leftof(), + rightof(), + place_l(0), + place_r(0), + dist(desiredDist), + b(0), + left(NULL), + right(NULL), + lap2(1.0/(desiredDist*desiredDist)), + g(0), + old_place_l(0), + old_place_r(0) + {} + CList leftof; // variables to which left dummy var must be to the left of CList rightof; // variables to which right dummy var must be to the right of double place_l; diff --git a/src/libcola/straightener.cpp b/src/libcola/straightener.cpp index fab30d48d..9e1ab1809 100644 --- a/src/libcola/straightener.cpp +++ b/src/libcola/straightener.cpp @@ -82,7 +82,7 @@ namespace straightener { double bx=route->xs[i]; double by=route->ys[i]; double t=0; - list<unsigned>::iterator copyit=j++; + list<unsigned>::iterator copyit=++j; //printf(" px=%f, py=%f, ax=%f, ay=%f, bx=%f, by=%f\n",px,py,ax,ay,bx,by); if(pointOnLine(px,py,ax,ay,bx,by,t)) { //printf(" got node %d\n",*copyit); diff --git a/src/libcola/straightener.h b/src/libcola/straightener.h index b1ce665f4..927780140 100644 --- a/src/libcola/straightener.h +++ b/src/libcola/straightener.h @@ -38,7 +38,7 @@ namespace straightener { std::vector<unsigned> dummyNodes; std::vector<unsigned> path; Edge(unsigned id, unsigned start, unsigned end, Route* route) - : id(id), startNode(start), endNode(end), route(route) + : id(id), openInd(0), startNode(start), endNode(end), route(route) { route->boundingBox(xmin,ymin,xmax,ymax); } @@ -98,7 +98,7 @@ namespace straightener { double weight; bool open; Node(unsigned id, vpsc::Rectangle* r) : - id(id),x(r->getCentreX()),y(r->getCentreY()), width(r->width()), height(r->height()), + id(id),x(r->getCentreX()),y(r->getCentreY()), scanpos(0), width(r->width()), height(r->height()), xmin(x-width/2),xmax(x+width/2), ymin(y-height/2),ymax(y+height/2), edge(NULL),dummy(false),weight(-0.1),open(false) { } diff --git a/src/libnrtype/TextWrapper.cpp b/src/libnrtype/TextWrapper.cpp index 63af17f2e..32877e275 100644 --- a/src/libnrtype/TextWrapper.cpp +++ b/src/libnrtype/TextWrapper.cpp @@ -107,8 +107,24 @@ void text_wrapper::AppendUTF8(char const *text, int len) /* effic: (Not an issue for the sole caller at the time of writing.) This implementation takes quadratic time if the text is composed of n appends. Use a proper data structure. STL vector would suffice. */ - utf8_text = (char*)realloc(utf8_text, (utf8_length + nlen + 1) * sizeof(char)); - uni32_codepoint = (int*)realloc(uni32_codepoint, (utf8_length + nlen + 1) * sizeof(int)); + char *newdata = static_cast<char*>(realloc(utf8_text, (utf8_length + nlen + 1) * sizeof(char))); + if (newdata != NULL) + { + utf8_text = newdata; + } + else + { + g_warning("Failed to reallocate utf8_text"); + } + int* newdata2 = static_cast<int*>(realloc(uni32_codepoint, (utf8_length + nlen + 1) * sizeof(int))); + if (newdata2 != NULL) + { + uni32_codepoint = newdata2; + } + else + { + g_warning("Failed to reallocate uni32_codepoint"); + } // copy the source text in the newly lengthened array memcpy(utf8_text + utf8_length, text, nlen * sizeof(char)); @@ -164,11 +180,27 @@ void text_wrapper::AppendUTF8(char const *text, int len) // so setting the dx to 0 is mandatory if ( uni32_length > last_addition ) { if ( kern_x ) { - kern_x = (double*)realloc(kern_x, (uni32_length + 1) * sizeof(double)); + double *newdata = static_cast<double*>(realloc(kern_x, (uni32_length + 1) * sizeof(double))); + if (newdata != NULL) + { + kern_x = newdata; + } + else + { + g_warning("Failed to reallocate kern_x"); + } for (int i = last_addition; i <= uni32_length; i++) kern_x[i] = 0; } if ( kern_y ) { - kern_y = (double*)realloc(kern_y, (uni32_length + 1) * sizeof(double)); + double *newdata = static_cast<double*>(realloc(kern_y, (uni32_length + 1) * sizeof(double))); + if (newdata != NULL) + { + kern_y = newdata; + } + else + { + g_warning("Failed to reallocate kern_y"); + } for (int i = last_addition; i <= uni32_length; i++) kern_y[i] = 0; } } @@ -214,7 +246,15 @@ void text_wrapper::DoLayout(void) // realloc the structures if ( glyph_length >= max_g ) { max_g = 2 * glyph_length + 1; - glyph_text = (one_glyph*)realloc(glyph_text, (max_g + 1) * sizeof(one_glyph)); + one_glyph *newdata = static_cast<one_glyph*>(realloc(glyph_text, (max_g + 1) * sizeof(one_glyph))); + if (newdata != NULL) + { + glyph_text = newdata; + } + else + { + g_warning("Failed to reallocate glyph_text"); + } } // fill the glyph info glyph_text[glyph_length].font = pRun->item->analysis.font; @@ -354,7 +394,15 @@ void text_wrapper::ChunkText(void) } while ( n_en < g_en && glyph_text[n_en].font == curPF ); if ( nbBox >= maxBox ) { maxBox = 2 * nbBox + 1; - boxes = (one_box*)realloc(boxes, maxBox * sizeof(one_box)); + one_box *newdata = static_cast<one_box*>(realloc(boxes, maxBox * sizeof(one_box))); + if (newdata != NULL) + { + boxes = newdata; + } + else + { + g_warning("Failed to reallocate boxes"); + } } boxes[nbBox].g_st = n_st; boxes[nbBox].g_en = n_en; @@ -378,7 +426,15 @@ void text_wrapper::ChunkText(void) if ( b_en < nbBox && boxes[b_en].g_en == g_en ) { if ( nbPara >= maxPara ) { maxPara = 2 * nbPara + 1; - paras = (one_para*)realloc(paras, maxPara * sizeof(one_para)); + one_para *newdata = static_cast<one_para*>(realloc(paras, maxPara * sizeof(one_para))); + if (newdata != NULL) + { + paras = newdata; + } + else + { + g_warning("Failed to reallocate paras"); + } } paras[nbPara].b_st = b_st; paras[nbPara].b_en = b_en; @@ -571,7 +627,15 @@ unsigned text_wrapper::AddBoundary(text_boundary const &ib) { if ( nbBound >= maxBound ) { maxBound = 2 * nbBound + 1; - bounds = (text_boundary*)realloc(bounds, maxBound * sizeof(text_boundary)); + text_boundary *newdata = static_cast<text_boundary*>(realloc(bounds, maxBound * sizeof(text_boundary))); + if (newdata != NULL) + { + bounds = newdata; + } + else + { + g_warning("Failed to reallocate bounds"); + } } unsigned const ix = nbBound++; bounds[ix] = ib; @@ -893,7 +957,7 @@ void text_wrapper::AddDxDy(void) } else if ( l_pos > n_pos ) { for (int j = l_pos; j > n_pos; j--) sum -= kern_x[j]; } - l_pos = n_pos; + // l_pos = n_pos; glyph_text[glyph_length].x += sum; } } @@ -918,7 +982,7 @@ void text_wrapper::AddDxDy(void) } else if ( l_pos > n_pos ) { for (int j = l_pos; j > n_pos; j--) sum -= kern_y[j]; } - l_pos = n_pos; + // l_pos = n_pos; glyph_text[glyph_length].y += sum; } } diff --git a/src/libuemf/uemf.c b/src/libuemf/uemf.c index b06990dbd..220c88545 100644 --- a/src/libuemf/uemf.c +++ b/src/libuemf/uemf.c @@ -1371,8 +1371,8 @@ int emf_htable_create( } ehtl->stack = malloc(initsize * sizeof(uint32_t)); if(!ehtl->stack){ - free(ehtl); free(ehtl->table); + free(ehtl); return(5); } memset(ehtl->table , 0, initsize * sizeof(uint32_t)); // zero all slots in the table diff --git a/src/libuemf/uemf_print.c b/src/libuemf/uemf_print.c index b4e1753c6..b7cbf9a14 100644 --- a/src/libuemf/uemf_print.c +++ b/src/libuemf/uemf_print.c @@ -735,7 +735,7 @@ void core10_print(const char *name, const char *contents){ printf(" Points: "); PU_POINT16 papts = (PU_POINT16)((char *)pEmr->aPolyCounts + sizeof(uint32_t)* pEmr->nPolys); for(i=0; i<pEmr->cpts; i++){ - printf(" [%d]:",i); point16_print(papts[i]); + printf(" [%u]:",i); point16_print(papts[i]); } printf("\n"); diff --git a/src/libvpsc/constraint.cpp b/src/libvpsc/constraint.cpp index 2bd173155..0ec06dfac 100644 --- a/src/libvpsc/constraint.cpp +++ b/src/libvpsc/constraint.cpp @@ -24,11 +24,11 @@ Constraint::Constraint(Variable *left, Variable *right, double gap, bool equalit } Constraint::~Constraint() { Constraints::iterator i; - for(i=left->out.begin(); i!=left->out.end(); i++) { + for(i=left->out.begin(); i!=left->out.end(); ++i) { if(*i==this) break; } left->out.erase(i); - for(i=right->in.begin(); i!=right->in.end(); i++) { + for(i=right->in.begin(); i!=right->in.end(); ++i) { if(*i==this) break; } right->in.erase(i); diff --git a/src/livarot/PathOutline.cpp b/src/livarot/PathOutline.cpp index 3b5ce79f9..2cd359328 100644 --- a/src/livarot/PathOutline.cpp +++ b/src/livarot/PathOutline.cpp @@ -1047,7 +1047,7 @@ void Path::TangentOnArcAt(double at, const Geom::Point &iS, PathDescrArcTo const dtgt[0] = -ca * rx * cb + sa * ry * sb; dtgt[1] = -sa * rx * cb - ca * ry * sb; len = L2(tgt); - rad = len * dot(tgt, tgt) / (tgt[0] * dtgt[1] - tgt[1] * dtgt[0]); + rad = -len * dot(tgt, tgt) / (tgt[0] * dtgt[1] - tgt[1] * dtgt[0]); tgt /= len; } else @@ -1476,7 +1476,7 @@ Path::RecStdArcTo (outline_callback_data * data, double tol, double width, } const Geom::Point diff = req - chk; const double err = (dot(diff,diff)); - if (err <= tol * tol) + if (err <= tol) // tolerance is given as a quadratic value, no need to use tol*tol here { int n_d = data->dest->CubicTo (enPos + width*enNor, stGue*scal*stTgt, diff --git a/src/livarot/Shape.cpp b/src/livarot/Shape.cpp index 628e0fe9f..ac6c72342 100644 --- a/src/livarot/Shape.cpp +++ b/src/livarot/Shape.cpp @@ -59,10 +59,10 @@ void Shape::Affiche(void) { printf("sh=%p nbPt=%i nbAr=%i\n", this, static_cast<int>(_pts.size()), static_cast<int>(_aretes.size())); // localizing ok for (unsigned int i=0; i<_pts.size(); i++) { - printf("pt %i : x=(%f %f) dI=%i dO=%i\n",i, _pts[i].x[0], _pts[i].x[1], _pts[i].dI, _pts[i].dO); // localizing ok + printf("pt %u : x=(%f %f) dI=%i dO=%i\n",i, _pts[i].x[0], _pts[i].x[1], _pts[i].dI, _pts[i].dO); // localizing ok } for (unsigned int i=0; i<_aretes.size(); i++) { - printf("ar %i : dx=(%f %f) st=%i en=%i\n",i, _aretes[i].dx[0], _aretes[i].dx[1], _aretes[i].st, _aretes[i].en); // localizing ok + printf("ar %u : dx=(%f %f) st=%i en=%i\n",i, _aretes[i].dx[0], _aretes[i].dx[1], _aretes[i].st, _aretes[i].en); // localizing ok } } diff --git a/src/seltrans.cpp b/src/seltrans.cpp index 7a8f5ec17..ed0fd3a08 100644 --- a/src/seltrans.cpp +++ b/src/seltrans.cpp @@ -1394,7 +1394,7 @@ void Inkscape::SelTrans::moveTo(Geom::Point const &xy, guint state) /* Pick one */ Inkscape::SnappedPoint best_snapped_point; - for (std::list<Inkscape::SnappedPoint>::const_iterator i = s.begin(); i != s.end(); i++) { + for (std::list<Inkscape::SnappedPoint>::const_iterator i = s.begin(); i != s.end(); ++i) { if (i->getSnapped()) { if (best_snapped_point.isOtherSnapBetter(*i, true)) { best_snapped_point = *i; diff --git a/src/xml/repr-io.cpp b/src/xml/repr-io.cpp index f7e75a83b..54eff00bc 100644 --- a/src/xml/repr-io.cpp +++ b/src/xml/repr-io.cpp @@ -78,11 +78,14 @@ public: XmlSource() : filename(0), encoding(0), - fp(0), + fp(NULL), firstFewLen(0), + LoadEntities(false), + cachedData(), + cachedPos(0), dummy("x"), - instr(0), - gzin(0) + instr(NULL), + gzin(NULL) { for (int k=0;k<4;k++) { @@ -191,7 +194,7 @@ int XmlSource::setFile(char const *filename, bool load_entities=false) buffer[len] = 0; this->cachedData += buffer; } - free(buffer); + delete[] buffer; // Check for SYSTEM or PUBLIC entities and remove them from the cache GMatchInfo *info; |
