From 85288191bbf9afd5d91b2bd0b0ea5d0e5c270ce0 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Tue, 22 Oct 2013 10:34:00 +0200 Subject: Fix for Bug #1022543 (Ctrl+C increments the documents count). Fixed bugs: - https://launchpad.net/bugs/1022543 (bzr r12712) --- src/document.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'src/document.cpp') diff --git a/src/document.cpp b/src/document.cpp index 4f57cf080..41defcc01 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); } } -- cgit v1.2.3 From fadaf147c5add875593a8fbf4933e890c0d4ed83 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Thu, 24 Oct 2013 16:21:44 +0200 Subject: fix crash bug 1237676 Fixed bugs: - https://launchpad.net/bugs/1237676 (bzr r12716) --- src/document.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/document.cpp') diff --git a/src/document.cpp b/src/document.cpp index 41defcc01..4a3d40308 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -1475,9 +1475,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(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(parent->get_data("desktopwidget")); + dtw->updateTitle( this->getName() ); + } } } -- cgit v1.2.3 From 651b367a2e01f918435d829394baff45537f6b91 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Thu, 24 Oct 2013 17:03:01 +0200 Subject: fix bug "some of the locale-based templates cause objects to be resized when default units are changed" #1236257 Fixed bugs: - https://launchpad.net/bugs/1236257 (bzr r12717) --- src/document.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/document.cpp') diff --git a/src/document.cpp b/src/document.cpp index 4a3d40308..782eb22f3 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -558,6 +558,13 @@ SPDocument *SPDocument::doUnref() return NULL; } +/// guaranteed not to return nullptr +Inkscape::Util::Unit const* SPDocument::getDefaultUnit() +{ + 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(""))); -- cgit v1.2.3 From 88ff8a79ec45f9591e764fce4244315b105f3cb6 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Thu, 24 Oct 2013 17:14:16 +0200 Subject: fix bad style (bzr r12718) --- src/document.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/document.cpp') diff --git a/src/document.cpp b/src/document.cpp index 782eb22f3..e1df38da1 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -679,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) { -- cgit v1.2.3 From 9c27ef4d920ac6b05cd052cf48fa1d0b85b194b9 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Thu, 24 Oct 2013 18:04:08 +0200 Subject: try to add some const-correctness (bzr r12719) --- src/document.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/document.cpp') diff --git a/src/document.cpp b/src/document.cpp index e1df38da1..3433e42ec 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -559,7 +559,7 @@ SPDocument *SPDocument::doUnref() } /// guaranteed not to return nullptr -Inkscape::Util::Unit const* SPDocument::getDefaultUnit() +Inkscape::Util::Unit const* SPDocument::getDefaultUnit() const { SPNamedView const* nv = sp_document_namedview(this, NULL); return nv ? nv->getDefaultUnit() : unit_table.getUnit("pt"); -- cgit v1.2.3