diff options
| author | Jabier Arraiza Cenoz <jabier.arraiza@marker.es> | 2013-10-26 12:27:05 +0000 |
|---|---|---|
| committer | Jabiertxof <jtx@jtx.marker.es> | 2013-10-26 12:27:05 +0000 |
| commit | 9b2d4924cf0f30df461236c7850c8e38480d8ad3 (patch) | |
| tree | 560ebd4e32dc9c9645287e8f5a8470bde91d7817 /src | |
| parent | Update to trunk (diff) | |
| parent | Fix memleak in reference counting introduced in r12532. (diff) | |
| download | inkscape-9b2d4924cf0f30df461236c7850c8e38480d8ad3.tar.gz inkscape-9b2d4924cf0f30df461236c7850c8e38480d8ad3.zip | |
Update to trunk
(bzr r11950.1.189)
Diffstat (limited to 'src')
| -rw-r--r-- | src/conn-avoid-ref.cpp | 30 | ||||
| -rw-r--r-- | src/document.cpp | 34 | ||||
| -rw-r--r-- | src/document.h | 3 | ||||
| -rw-r--r-- | src/extension/dbus/Makefile_insert | 3 | ||||
| -rw-r--r-- | src/extension/internal/cdr-input.cpp | 2 | ||||
| -rw-r--r-- | src/extension/internal/emf-inout.cpp | 25 | ||||
| -rw-r--r-- | src/extension/internal/gdkpixbuf-input.cpp | 2 | ||||
| -rw-r--r-- | src/extension/internal/image-resolution.cpp | 11 | ||||
| -rw-r--r-- | src/extension/internal/pdf-input-cairo.cpp | 2 | ||||
| -rw-r--r-- | src/extension/internal/pdfinput/pdf-input.cpp | 2 | ||||
| -rw-r--r-- | src/extension/internal/vsd-input.cpp | 2 | ||||
| -rw-r--r-- | src/extension/internal/wmf-inout.cpp | 12 | ||||
| -rw-r--r-- | src/extension/internal/wmf-print.cpp | 5 | ||||
| -rw-r--r-- | src/extension/internal/wpg-input.cpp | 2 | ||||
| -rw-r--r-- | src/file.cpp | 2 | ||||
| -rw-r--r-- | src/interface.cpp | 2 | ||||
| -rw-r--r-- | src/libdepixelize/priv/point.h | 4 | ||||
| -rw-r--r-- | src/libuemf/uemf.h | 1 | ||||
| -rw-r--r-- | src/libvpsc/solve_VPSC.cpp | 12 | ||||
| -rw-r--r-- | src/sp-namedview.cpp | 5 | ||||
| -rw-r--r-- | src/sp-namedview.h | 1 | ||||
| -rw-r--r-- | src/sp-object.cpp | 2 | ||||
| -rw-r--r-- | src/sp-rect.cpp | 2 | ||||
| -rw-r--r-- | src/ui/dialog/document-properties.cpp | 22 |
24 files changed, 124 insertions, 64 deletions
diff --git a/src/conn-avoid-ref.cpp b/src/conn-avoid-ref.cpp index c0d05e3c4..cb72f65dc 100644 --- a/src/conn-avoid-ref.cpp +++ b/src/conn-avoid-ref.cpp @@ -303,23 +303,29 @@ static Avoid::Polygon avoid_item_poly(SPItem const *item) Geom::Line parallel_hull_edge; parallel_hull_edge.setOrigin(hull_edge.origin()+hull_edge.versor().ccw()*spacing); parallel_hull_edge.setVersor(hull_edge.versor()); - + // determine the intersection point - - Geom::OptCrossing int_pt = Geom::intersection(parallel_hull_edge, prev_parallel_hull_edge); - if (int_pt) - { - Avoid::Point avoid_pt((parallel_hull_edge.origin()+parallel_hull_edge.versor()*int_pt->ta)[Geom::X], - (parallel_hull_edge.origin()+parallel_hull_edge.versor()*int_pt->ta)[Geom::Y]); - poly.ps.push_back(avoid_pt); + try { + Geom::OptCrossing int_pt = Geom::intersection(parallel_hull_edge, prev_parallel_hull_edge); + if (int_pt) + { + Avoid::Point avoid_pt((parallel_hull_edge.origin()+parallel_hull_edge.versor()*int_pt->ta)[Geom::X], + (parallel_hull_edge.origin()+parallel_hull_edge.versor()*int_pt->ta)[Geom::Y]); + poly.ps.push_back(avoid_pt); + } + else + { + // something went wrong... + std::cout<<"conn-avoid-ref.cpp: avoid_item_poly: Geom:intersection failed."<<std::endl; + } } - else - { - // something went wrong... - std::cout<<"conn-avoid-ref.cpp: avoid_item_poly: Geom:intersection failed."<<std::endl; + catch (Geom::InfiniteSolutions const &e) { + // the parallel_hull_edge and prev_parallel_hull_edge lie on top of each other, hence infinite crossings + g_message("conn-avoid-ref.cpp: trying to get crossings of identical lines"); } prev_parallel_hull_edge = parallel_hull_edge; } + return poly; } diff --git a/src/document.cpp b/src/document.cpp index 4f57cf080..3433e42ec 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -84,6 +84,7 @@ static gint sp_document_rerouting_handler(gpointer data); gboolean sp_document_resource_list_free(gpointer key, gpointer value, gpointer data); static gint doc_count = 0; +static gint doc_mem_count = 0; static unsigned long next_serial = 0; @@ -500,15 +501,18 @@ SPDocument *SPDocument::createNewDoc(gchar const *uri, unsigned int keepalive, b base = NULL; name = g_strdup(uri); } + if (make_new) { + base = NULL; + uri = NULL; + name = g_strdup_printf(_("New document %d"), ++doc_count); + } g_free(s); } else { - rdoc = sp_repr_document_new("svg:svg"); - } + if (make_new) { + name = g_strdup_printf(_("Memory document %d"), ++doc_mem_count); + } - if (make_new) { - base = NULL; - uri = NULL; - name = g_strdup_printf(_("New document %d"), ++doc_count); + rdoc = sp_repr_document_new("svg:svg"); } //# These should be set by now @@ -534,7 +538,7 @@ SPDocument *SPDocument::createNewDocFromMem(gchar const *buffer, gint length, un // If xml file is not svg, return NULL without warning // TODO fixme: destroy document } else { - Glib::ustring name = Glib::ustring::compose( _("Memory document %1"), ++doc_count ); + Glib::ustring name = Glib::ustring::compose( _("Memory document %1"), ++doc_mem_count ); doc = createDoc(rdoc, NULL, NULL, name.c_str(), keepalive); } } @@ -554,6 +558,13 @@ SPDocument *SPDocument::doUnref() return NULL; } +/// guaranteed not to return nullptr +Inkscape::Util::Unit const* SPDocument::getDefaultUnit() const +{ + SPNamedView const* nv = sp_document_namedview(this, NULL); + return nv ? nv->getDefaultUnit() : unit_table.getUnit("pt"); +} + Inkscape::Util::Quantity SPDocument::getWidth() const { g_return_val_if_fail(this->priv != NULL, Inkscape::Util::Quantity(0.0, unit_table.getUnit(""))); @@ -668,7 +679,7 @@ void SPDocument::fitToRect(Geom::Rect const &rect, bool with_margins) double margin_right = 0.0; double margin_bottom = 0.0; - SPNamedView *nv = sp_document_namedview(this, 0); + SPNamedView *nv = sp_document_namedview(this, NULL); if (with_margins && nv) { if (nv != NULL) { @@ -1471,9 +1482,10 @@ void SPDocument::setModifiedSinceSave(bool modified) { this->modified_since_save = modified; if (SP_ACTIVE_DESKTOP) { Gtk::Window *parent = SP_ACTIVE_DESKTOP->getToplevel(); - g_assert(parent != NULL); - SPDesktopWidget *dtw = static_cast<SPDesktopWidget *>(parent->get_data("desktopwidget")); - dtw->updateTitle( this->getName() ); + if (parent) { // during load, SP_ACTIVE_DESKTOP may be !nullptr, but parent might still be nullptr + SPDesktopWidget *dtw = static_cast<SPDesktopWidget *>(parent->get_data("desktopwidget")); + dtw->updateTitle( this->getName() ); + } } } diff --git a/src/document.h b/src/document.h index 948b5b867..0977fc7a8 100644 --- a/src/document.h +++ b/src/document.h @@ -47,6 +47,7 @@ namespace Inkscape { class Node; } namespace Util { + class Unit; class Quantity; } } @@ -123,6 +124,7 @@ public: /** Returns our SPRoot */ SPRoot *getRoot() { return root; } + SPRoot const *getRoot() const { return root; } Inkscape::XML::Node *getReprRoot() { return rroot; } @@ -227,6 +229,7 @@ public: SPDocument *doRef(); SPDocument *doUnref(); + Inkscape::Util::Unit const* getDefaultUnit() const; Inkscape::Util::Quantity getWidth() const; Inkscape::Util::Quantity getHeight() const; Geom::Point getDimensions() const; diff --git a/src/extension/dbus/Makefile_insert b/src/extension/dbus/Makefile_insert index a5eb3fdf4..7d851715e 100644 --- a/src/extension/dbus/Makefile_insert +++ b/src/extension/dbus/Makefile_insert @@ -12,7 +12,8 @@ ink_common_sources += \ extension/dbus/application-interface.cpp \ extension/dbus/application-interface.h \ extension/dbus/document-interface.cpp \ - extension/dbus/document-interface.h + extension/dbus/document-interface.h \ + extension/dbus/org.inkscape.service.in ########################### # Build DBus wrapper files diff --git a/src/extension/internal/cdr-input.cpp b/src/extension/internal/cdr-input.cpp index 517d6fb9c..04087e268 100644 --- a/src/extension/internal/cdr-input.cpp +++ b/src/extension/internal/cdr-input.cpp @@ -258,7 +258,7 @@ SPDocument *CdrInput::open(Inkscape::Extension::Input * /*mod*/, const gchar * u SPDocument * doc = SPDocument::createNewDocFromMem(tmpSVGOutput[page_num-1].cstr(), strlen(tmpSVGOutput[page_num-1].cstr()), TRUE); // Set viewBox if it doesn't exist if (!doc->getRoot()->viewBox_set) { - doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().quantity, doc->getHeight().quantity)); + doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().value(doc->getDefaultUnit()), doc->getHeight().value(doc->getDefaultUnit()))); } return doc; } diff --git a/src/extension/internal/emf-inout.cpp b/src/extension/internal/emf-inout.cpp index f1876c687..36d7ca145 100644 --- a/src/extension/internal/emf-inout.cpp +++ b/src/extension/internal/emf-inout.cpp @@ -789,8 +789,12 @@ Emf::output_style(PEMF_CALLBACK_DATA d, int iType) // Assume src color is "white" if(d->dwRop3){ switch(d->dwRop3){ - case U_PATINVERT: // treat all of these as black - case U_SRCINVERT: + case U_PATINVERT: // invert pattern + fill_rgb[0] = 1.0 - fill_rgb[0]; + fill_rgb[1] = 1.0 - fill_rgb[1]; + fill_rgb[2] = 1.0 - fill_rgb[2]; + break; + case U_SRCINVERT: // treat all of these as black case U_DSTINVERT: case U_BLACKNESS: case U_SRCERASE: @@ -799,7 +803,6 @@ Emf::output_style(PEMF_CALLBACK_DATA d, int iType) break; case U_SRCCOPY: // treat all of these as white case U_NOTSRCERASE: - case U_PATCOPY: case U_WHITENESS: fill_rgb[0]=fill_rgb[1]=fill_rgb[2]=1.0; break; @@ -808,6 +811,7 @@ Emf::output_style(PEMF_CALLBACK_DATA d, int iType) case U_MERGECOPY: case U_MERGEPAINT: case U_PATPAINT: + case U_PATCOPY: default: break; } @@ -2747,7 +2751,10 @@ std::cout << "BEFORE DRAW" { dbg_str << "<!-- U_EMR_BEGINPATH -->\n"; // The next line should never be needed, should have been handled before main switch - *(d->path) = ""; + // qualifier added because EMF's encountered where moveto preceded beginpath followed by lineto + if(d->mask & U_DRAW_VISIBLE){ + *(d->path) = ""; + } d->mask |= emr_mask; break; } @@ -2859,6 +2866,7 @@ std::cout << "BEFORE DRAW" if (!pEmr->cbBmiSrc) { // should be an application of a DIBPATTERNBRUSHPT, use a solid color instead + if(pEmr->dwRop == U_NOOP)break; /* GDI applications apparently often end with this as a sort of flush(), nothing should be drawn */ int32_t dx = pEmr->Dest.x; int32_t dy = pEmr->Dest.y; int32_t dw = pEmr->cDest.x; @@ -3497,12 +3505,13 @@ Emf::open( Inkscape::Extension::Input * /*mod*/, const gchar *uri ) // Set document unit Inkscape::XML::Node *repr = sp_document_namedview(doc, 0)->getRepr(); Inkscape::SVGOStringStream os; - os << doc->getWidth().unit->abbr; + Inkscape::Util::Unit const* doc_unit = doc->getWidth().unit; + os << doc_unit->abbr; repr->setAttribute("inkscape:document-units", os.str().c_str()); - + // Set viewBox - doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().quantity, doc->getHeight().quantity)); - + doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().value(doc_unit), doc->getHeight().value(doc_unit))); + // Scale and translate objects double scale = Inkscape::Util::Quantity::convert(1, "px", doc->getWidth().unit); ShapeEditor::blockSetItem(true); diff --git a/src/extension/internal/gdkpixbuf-input.cpp b/src/extension/internal/gdkpixbuf-input.cpp index 13267ee2b..6d159d265 100644 --- a/src/extension/internal/gdkpixbuf-input.cpp +++ b/src/extension/internal/gdkpixbuf-input.cpp @@ -105,7 +105,7 @@ GdkpixbufInput::open(Inkscape::Extension::Input *mod, char const *uri) // Set viewBox if it doesn't exist if (!doc->getRoot()->viewBox_set) { - doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().quantity, doc->getHeight().quantity)); + doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().value(doc->getDefaultUnit()), doc->getHeight().value(doc->getDefaultUnit()))); } // restore undo, as now this document may be shown to the user if a bitmap was opened diff --git a/src/extension/internal/image-resolution.cpp b/src/extension/internal/image-resolution.cpp index b38b0ddc7..865e86698 100644 --- a/src/extension/internal/image-resolution.cpp +++ b/src/extension/internal/image-resolution.cpp @@ -342,9 +342,16 @@ void ImageResolution::readmagick(char const *fn) { image.read(fn); } catch (...) {} Magick::Geometry geo = image.density(); + std::string type = image.magick(); + + if (type == "PNG") { // PNG only supports pixelspercentimeter + x_ = Inkscape::Util::Quantity::convert((double)geo.width(), "in", "cm"); + y_ = Inkscape::Util::Quantity::convert((double)geo.height(), "in", "cm"); + } else { + x_ = (double)geo.width(); + y_ = (double)geo.height(); + } - x_ = Inkscape::Util::Quantity::convert((double)geo.width(), "pt", "px"); - y_ = Inkscape::Util::Quantity::convert((double)geo.height(), "pt", "px"); ok_ = true; } diff --git a/src/extension/internal/pdf-input-cairo.cpp b/src/extension/internal/pdf-input-cairo.cpp index adac0d6c9..f47fbaf87 100644 --- a/src/extension/internal/pdf-input-cairo.cpp +++ b/src/extension/internal/pdf-input-cairo.cpp @@ -626,7 +626,7 @@ PdfInputCairo::open(Inkscape::Extension::Input * /*mod*/, const gchar * uri) { // Set viewBox if it doesn't exist if (!doc->getRoot()->viewBox_set) { - doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().quantity, doc->getHeight().quantity)); + doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().value(doc->getDefaultUnit()), doc->getHeight().value(doc->getDefaultUnit()))); } delete output; diff --git a/src/extension/internal/pdfinput/pdf-input.cpp b/src/extension/internal/pdfinput/pdf-input.cpp index 213550688..3155ac098 100644 --- a/src/extension/internal/pdfinput/pdf-input.cpp +++ b/src/extension/internal/pdfinput/pdf-input.cpp @@ -750,7 +750,7 @@ PdfInput::open(::Inkscape::Extension::Input * /*mod*/, const gchar * uri) { // Set viewBox if it doesn't exist if (!doc->getRoot()->viewBox_set) { - doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().quantity, doc->getHeight().quantity)); + doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().value(doc->getDefaultUnit()), doc->getHeight().value(doc->getDefaultUnit()))); } // Restore undo diff --git a/src/extension/internal/vsd-input.cpp b/src/extension/internal/vsd-input.cpp index 42a9e3d41..6fc79237b 100644 --- a/src/extension/internal/vsd-input.cpp +++ b/src/extension/internal/vsd-input.cpp @@ -258,7 +258,7 @@ SPDocument *VsdInput::open(Inkscape::Extension::Input * /*mod*/, const gchar * u // Set viewBox if it doesn't exist if (!doc->getRoot()->viewBox_set) { - doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().quantity, doc->getHeight().quantity)); + doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().value(doc->getDefaultUnit()), doc->getHeight().value(doc->getDefaultUnit()))); } return doc; diff --git a/src/extension/internal/wmf-inout.cpp b/src/extension/internal/wmf-inout.cpp index d69d46f20..2e55dcb1e 100644 --- a/src/extension/internal/wmf-inout.cpp +++ b/src/extension/internal/wmf-inout.cpp @@ -1970,7 +1970,9 @@ std::cout << "BEFORE DRAW" } if (!d->dc[d->level].sizeView.x || !d->dc[d->level].sizeView.y) { - d->dc[d->level].sizeView = d->dc[d->level].sizeWnd; + /* Previously it used sizeWnd, but that always resulted in scale = 1 if no viewport ever appeared, and in most files, it did not */ + d->dc[d->level].sizeView.x = d->PixelsInX - 1; + d->dc[d->level].sizeView.y = d->PixelsInY - 1; } /* scales logical to WMF pixels, transfer a negative sign on Y, if any */ @@ -2284,6 +2286,7 @@ std::cout << "BEFORE DRAW" dbg_str << "<!-- U_WMR_BITBLT -->\n"; nSize = U_WMRBITBLT_get(contents,&Dst,&cwh,&Src,&dwRop3,&Bm16,&px); if(!px){ + if(dwRop3 == U_NOOP)break; /* GDI applications apparently often end with this as a sort of flush(), nothing should be drawn */ int32_t dx = Dst.x; int32_t dy = Dst.y; int32_t dw = cwh.x; @@ -2321,6 +2324,7 @@ std::cout << "BEFORE DRAW" dbg_str << "<!-- U_WMR_STRETCHBLT -->\n"; nSize = U_WMRSTRETCHBLT_get(contents,&Dst,&cDst,&Src,&cSrc,&dwRop3,&Bm16,&px); if(!px){ + if(dwRop3 == U_NOOP)break; /* GDI applications apparently often end with this as a sort of flush(), nothing should be drawn */ int32_t dx = Dst.x; int32_t dy = Dst.y; int32_t dw = cDst.x; @@ -2715,6 +2719,7 @@ std::cout << "BEFORE DRAW" if (!dib) { // should be an application of a DIBPATTERNBRUSHPT, use a solid color instead + if(dwRop3 == U_NOOP)break; /* GDI applications apparently often end with this as a sort of flush(), nothing should be drawn */ int32_t dx = Dst.x; int32_t dy = Dst.y; int32_t dw = cwh.x; @@ -3185,11 +3190,12 @@ Wmf::open( Inkscape::Extension::Input * /*mod*/, const gchar *uri ) // Set document unit Inkscape::XML::Node *repr = sp_document_namedview(doc, 0)->getRepr(); Inkscape::SVGOStringStream os; - os << doc->getWidth().unit->abbr; + Inkscape::Util::Unit const* doc_unit = doc->getWidth().unit; + os << doc_unit->abbr; repr->setAttribute("inkscape:document-units", os.str().c_str()); // Set viewBox - doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().quantity, doc->getHeight().quantity)); + doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().value(doc_unit), doc->getHeight().value(doc_unit))); // Scale and translate objects double scale = Inkscape::Util::Quantity::convert(1, "px", doc->getWidth().unit); diff --git a/src/extension/internal/wmf-print.cpp b/src/extension/internal/wmf-print.cpp index cf0302b38..3bb17146c 100644 --- a/src/extension/internal/wmf-print.cpp +++ b/src/extension/internal/wmf-print.cpp @@ -1120,6 +1120,9 @@ unsigned int PrintWmf::image( Geom::Point pLL(x1, y1); Geom::Point pLL2 = pLL * tf; //location of LL corner in Inkscape coordinates + Geom::Point pWH(dw, dh); + Geom::Point pWH2 = pWH * tf.withoutTranslation(); //adjust scale + char *px; uint32_t cbPx; uint32_t colortype; @@ -1133,7 +1136,7 @@ unsigned int PrintWmf::image( Bmi = bitmapinfo_set(Bmih, ct); U_POINT16 Dest = point16_set(round(pLL2[Geom::X] * PX2WORLD), round(pLL2[Geom::Y] * PX2WORLD)); - U_POINT16 cDest = point16_set(round(dw * PX2WORLD), round(dh * PX2WORLD)); + U_POINT16 cDest = point16_set(round(pWH2[Geom::X] * PX2WORLD), round(pWH2[Geom::Y] * PX2WORLD)); U_POINT16 Src = point16_set(0, 0); U_POINT16 cSrc = point16_set(w, h); rec = U_WMRSTRETCHDIB_set( diff --git a/src/extension/internal/wpg-input.cpp b/src/extension/internal/wpg-input.cpp index ac86a6171..b5eb3ce8f 100644 --- a/src/extension/internal/wpg-input.cpp +++ b/src/extension/internal/wpg-input.cpp @@ -114,7 +114,7 @@ SPDocument *WpgInput::open(Inkscape::Extension::Input * /*mod*/, const gchar * u // Set viewBox if it doesn't exist if (!doc->getRoot()->viewBox_set) { - doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().quantity, doc->getHeight().quantity)); + doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().value(doc->getDefaultUnit()), doc->getHeight().value(doc->getDefaultUnit()))); } delete input; diff --git a/src/file.cpp b/src/file.cpp index 8a7b177c0..f978ec66e 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -144,7 +144,7 @@ SPDesktop *sp_file_new(const std::string &templ) // Set viewBox if it doesn't exist if (!doc->getRoot()->viewBox_set) { DocumentUndo::setUndoSensitive(doc, false); - doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().quantity, doc->getHeight().quantity)); + doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().value(doc->getDefaultUnit()), doc->getHeight().value(doc->getDefaultUnit()))); DocumentUndo::setUndoSensitive(doc, true); } diff --git a/src/interface.cpp b/src/interface.cpp index e57092e2b..f411989ce 100644 --- a/src/interface.cpp +++ b/src/interface.cpp @@ -324,7 +324,7 @@ sp_ui_close_view(GtkWidget */*widget*/) SPDocument *doc = SPDocument::createNewDoc( templateUri.c_str() , TRUE, true ); // Set viewBox if it doesn't exist if (!doc->getRoot()->viewBox_set) { - doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().quantity, doc->getHeight().quantity)); + doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().value(doc->getDefaultUnit()), doc->getHeight().value(doc->getDefaultUnit()))); } dt->change_document(doc); sp_namedview_window_from_document(dt); diff --git a/src/libdepixelize/priv/point.h b/src/libdepixelize/priv/point.h index dc28a2b84..53babd9dc 100644 --- a/src/libdepixelize/priv/point.h +++ b/src/libdepixelize/priv/point.h @@ -30,8 +30,8 @@ namespace Tracer { template<class T> struct Point { - Point() : visible(true) {} - Point(T x, T y) : visible(true), x(x), y(y) {} + Point() : smooth(false), visible(true) {} + Point(T x, T y) : smooth(false), visible(true), x(x), y(y) {} Point(T x, T y, bool smooth) : smooth(smooth), visible(true), x(x), y(y) {} Point operator+(const Point &rhs) const diff --git a/src/libuemf/uemf.h b/src/libuemf/uemf.h index f1211d63d..1ff6ead60 100644 --- a/src/libuemf/uemf.h +++ b/src/libuemf/uemf.h @@ -856,6 +856,7 @@ extern "C" { #define U_DSTINVERT 0x550009 #define U_BLACKNESS 0x000042 #define U_WHITENESS 0xff0062 +#define U_NOOP 0xaa0029 /* Many GDI programs end with a bitblt with this ROP == "D". Seems to work like flush() */ /** @} */ /** \defgroup U_EMRSETROP2_iMode_Qualifiers Binary Raster Operation Enumeration diff --git a/src/libvpsc/solve_VPSC.cpp b/src/libvpsc/solve_VPSC.cpp index f9bed649c..83cb517b6 100644 --- a/src/libvpsc/solve_VPSC.cpp +++ b/src/libvpsc/solve_VPSC.cpp @@ -301,16 +301,16 @@ bool Solver::constraintGraphIsCyclic(const unsigned n, Variable* const vs[]) { varmap[vs[i]]->out.insert(varmap[r]); } } - while(graph.size()>0) { + while(!graph.empty()) { node *u=NULL; vector<node*>::iterator i=graph.begin(); for(;i!=graph.end();++i) { u=*i; - if(u->in.size()==0) { + if(u->in.empty()) { break; } } - if(i==graph.end() && graph.size()>0) { + if(i==graph.end() && !graph.empty()) { //cycle found! return true; } else { @@ -358,16 +358,16 @@ bool Solver::blockGraphIsCyclic() { c=b->findMinOutConstraint(); } } - while(graph.size()>0) { + while(!graph.empty()) { node *u=NULL; vector<node*>::iterator i=graph.begin(); for(;i!=graph.end();++i) { u=*i; - if(u->in.size()==0) { + if(u->in.empty()) { break; } } - if(i==graph.end() && graph.size()>0) { + if(i==graph.end() && !graph.empty()) { //cycle found! return true; } else { diff --git a/src/sp-namedview.cpp b/src/sp-namedview.cpp index ad497ff2f..a01ba891e 100644 --- a/src/sp-namedview.cpp +++ b/src/sp-namedview.cpp @@ -1073,6 +1073,11 @@ SPNamedView *sp_document_namedview(SPDocument *document, const gchar *id) return (SPNamedView *) nv; } +SPNamedView const *sp_document_namedview(SPDocument const *document, const gchar *id) +{ + return sp_document_namedview(const_cast<SPDocument *>(document), id); // use a const_cast here to avoid duplicating code +} + void SPNamedView::setGuides(bool v) { g_assert(this->getRepr() != NULL); diff --git a/src/sp-namedview.h b/src/sp-namedview.h index 00302e9a1..05cbcc398 100644 --- a/src/sp-namedview.h +++ b/src/sp-namedview.h @@ -110,6 +110,7 @@ protected: SPNamedView *sp_document_namedview(SPDocument *document, gchar const *name); +SPNamedView const *sp_document_namedview(SPDocument const *document, gchar const *name); void sp_namedview_window_from_document(SPDesktop *desktop); void sp_namedview_document_from_window(SPDesktop *desktop); diff --git a/src/sp-object.cpp b/src/sp-object.cpp index 2408370cf..e5f119ee0 100644 --- a/src/sp-object.cpp +++ b/src/sp-object.cpp @@ -228,7 +228,7 @@ SPObject *sp_object_unref(SPObject *object, SPObject *owner) //g_object_unref(G_OBJECT(object)); object->refCount--; - if (object->refCount < 0) { + if (object->refCount <= 0) { delete object; } diff --git a/src/sp-rect.cpp b/src/sp-rect.cpp index ff5e81f95..b327f0b83 100644 --- a/src/sp-rect.cpp +++ b/src/sp-rect.cpp @@ -113,7 +113,7 @@ void SPRect::set(unsigned key, gchar const *value) { void SPRect::update(SPCtx* ctx, unsigned int flags) { if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) { - SPItemCtx const *ictx = (SPItemCtx const *) ctx; + SPItemCtx const *ictx = reinterpret_cast<SPItemCtx const *>(ctx); double const w = ictx->viewport.width(); double const h = ictx->viewport.height(); diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp index a6019c55c..79fb953ac 100644 --- a/src/ui/dialog/document-properties.cpp +++ b/src/ui/dialog/document-properties.cpp @@ -173,7 +173,7 @@ DocumentProperties::DocumentProperties() signalDocumentReplaced().connect(sigc::mem_fun(*this, &DocumentProperties::_handleDocumentReplaced)); signalActivateDesktop().connect(sigc::mem_fun(*this, &DocumentProperties::_handleActivateDesktop)); signalDeactiveDesktop().connect(sigc::mem_fun(*this, &DocumentProperties::_handleDeactivateDesktop)); - + _rum_deflt._changed_connection.block(); _rum_deflt.getUnitMenu()->signal_changed().connect(sigc::mem_fun(*this, &DocumentProperties::onDocUnitChange)); } @@ -1437,8 +1437,9 @@ void DocumentProperties::update() _rcp_bord.setRgba32 (nv->bordercolor); _rcb_shad.setActive (nv->showpageshadow); - if (nv->doc_units) + if (nv->doc_units) { _rum_deflt.setUnit (nv->doc_units->abbr); + } double doc_w = sp_desktop_document(dt)->getRoot()->width.value; Glib::ustring doc_w_unit = unit_table.getUnit(sp_desktop_document(dt)->getRoot()->width.unit)->abbr; @@ -1643,18 +1644,23 @@ void DocumentProperties::onRemoveGrid() void DocumentProperties::onDocUnitChange() { SPDocument *doc = SP_ACTIVE_DOCUMENT; + // Don't execute when change is being undone + if (!DocumentUndo::getUndoSensitive(doc)) { + return; + } + // Don't execute when initializing widgets + if (_wr.isUpdating()) { + return; + } + + Inkscape::XML::Node *repr = sp_desktop_namedview(getDesktop())->getRepr(); Inkscape::Util::Unit const *old_doc_unit = unit_table.getUnit("px"); if(repr->attribute("inkscape:document-units")) { old_doc_unit = unit_table.getUnit(repr->attribute("inkscape:document-units")); } Inkscape::Util::Unit const *doc_unit = _rum_deflt.getUnit(); - - // Don't execute when change is being undone - if (!DocumentUndo::getUndoSensitive(doc)) { - return; - } - + // Set document unit Inkscape::SVGOStringStream os; os << doc_unit->abbr; |
