summaryrefslogtreecommitdiffstats
path: root/src/document.cpp
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2013-10-26 12:33:17 +0000
committerJabiertxof <jtx@jtx.marker.es>2013-10-26 12:33:17 +0000
commit7caf32d2b22680c603e4e88c76739c758630412c (patch)
treedaaf4e77d712bd802076980d7a077dc6562f3df7 /src/document.cpp
parentRemoved BSpline from tell by su_v (diff)
parentFix memleak in reference counting introduced in r12532. (diff)
downloadinkscape-7caf32d2b22680c603e4e88c76739c758630412c.tar.gz
inkscape-7caf32d2b22680c603e4e88c76739c758630412c.zip
Update to trunk
(bzr r12588.1.24)
Diffstat (limited to 'src/document.cpp')
-rw-r--r--src/document.cpp34
1 files changed, 23 insertions, 11 deletions
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() );
+ }
}
}