summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKris De Gussem <kris.degussem@gmail.com>2012-04-22 16:31:34 +0000
committerKris <Kris.De.Gussem@hotmail.com>2012-04-22 16:31:34 +0000
commitd23955d30e93b41c621047250480d75a55752419 (patch)
tree1bb0a93b9984502ef05443f00cc100f2ec5a4e65 /src
parentImprove pen & pencil anchor visibility. Fixes bug #986748. (diff)
downloadinkscape-d23955d30e93b41c621047250480d75a55752419.tar.gz
inkscape-d23955d30e93b41c621047250480d75a55752419.zip
some more string class usage
(bzr r11279)
Diffstat (limited to 'src')
-rw-r--r--src/main.cpp29
-rw-r--r--src/xml/repr-io.cpp22
2 files changed, 22 insertions, 29 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 7a5d15cb7..a22295424 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1253,10 +1253,9 @@ do_query_all_recurse (SPObject *o)
}
-static void
-sp_do_export_png(SPDocument *doc)
+static void sp_do_export_png(SPDocument *doc)
{
- const gchar *filename = NULL;
+ Glib::ustring filename;
bool filename_from_hint = false;
gdouble dpi = 0.0;
@@ -1356,7 +1355,7 @@ sp_do_export_png(SPDocument *doc)
}
// set filename and dpi from options, if not yet set from the hints
- if (!filename) {
+ if (filename.empty()) {
if (!sp_export_png) {
g_warning ("No export filename given and no filename hint. Nothing exported.");
return;
@@ -1447,36 +1446,34 @@ sp_do_export_png(SPDocument *doc)
}
}
- gchar *path = 0;
+ Glib::ustring path;
if (filename_from_hint) {
//Make relative paths go from the document location, if possible:
- if (!g_path_is_absolute(filename) && doc->getURI()) {
- gchar *dirname = g_path_get_dirname(doc->getURI());
- if (dirname) {
- path = g_build_filename(dirname, filename, NULL);
- g_free(dirname);
+ if (!Glib::path_is_absolute(filename) && doc->getURI()) {
+ Glib::ustring dirname = Glib::path_get_dirname(doc->getURI());
+ if (!dirname.empty()) {
+ path = Glib::build_filename(dirname, filename);
}
}
- if (!path) {
- path = g_strdup(filename);
+ if (path.empty()) {
+ path = filename;
}
} else {
- path = g_strdup(filename);
+ path = filename;
}
g_print("Background RRGGBBAA: %08x\n", bgcolor);
g_print("Area %g:%g:%g:%g exported to %lu x %lu pixels (%g dpi)\n", area[Geom::X][0], area[Geom::Y][0], area[Geom::X][1], area[Geom::Y][1], width, height, dpi);
- g_print("Bitmap saved as: %s\n", filename);
+ g_print("Bitmap saved as: %s\n", filename.c_str());
if ((width >= 1) && (height >= 1) && (width <= PNG_UINT_31_MAX) && (height <= PNG_UINT_31_MAX)) {
- sp_export_png_file(doc, path, area, width, height, dpi, dpi, bgcolor, NULL, NULL, true, sp_export_id_only ? items : NULL);
+ sp_export_png_file(doc, path.c_str(), area, width, height, dpi, dpi, bgcolor, NULL, NULL, true, sp_export_id_only ? items : NULL);
} else {
g_warning("Calculated bitmap dimensions %lu %lu are out of range (1 - %lu). Nothing exported.", width, height, (unsigned long int)PNG_UINT_31_MAX);
}
- g_free (path);
g_slist_free (items);
}
diff --git a/src/xml/repr-io.cpp b/src/xml/repr-io.cpp
index 355f3e2b3..b85e58899 100644
--- a/src/xml/repr-io.cpp
+++ b/src/xml/repr-io.cpp
@@ -625,7 +625,7 @@ void sp_repr_save_stream(Document *doc, FILE *fp, gchar const *default_ns, bool
/**
- * Returns true iff file successfully saved.
+ * Returns true if file successfully saved.
*
* \param filename The actual file to do I/O to, which might be a temp file.
*
@@ -652,27 +652,23 @@ bool sp_repr_save_rebased_file(Document *doc, gchar const *const filename, gchar
return false;
}
- std::string old_href_abs_base;
- gchar *new_href_abs_base = NULL;
+ Glib::ustring old_href_abs_base;
+ Glib::ustring new_href_abs_base;
if (for_filename) {
old_href_abs_base = calc_abs_doc_base(old_base);
- if (g_path_is_absolute(for_filename)) {
- new_href_abs_base = g_path_get_dirname(for_filename);
+ if (Glib::path_is_absolute(for_filename)) {
+ new_href_abs_base = Glib::path_get_dirname(for_filename);
} else {
- gchar *const cwd = g_get_current_dir();
- gchar *const for_abs_filename = g_build_filename(cwd, for_filename, NULL);
- g_free(cwd);
- new_href_abs_base = g_path_get_dirname(for_abs_filename);
- g_free(for_abs_filename);
+ Glib::ustring const cwd = Glib::get_current_dir();
+ Glib::ustring const for_abs_filename = Glib::build_filename(cwd, for_filename);
+ new_href_abs_base = Glib::path_get_dirname(for_abs_filename);
}
/* effic: Once we're confident that we never need (or never want) to resort
* to using sodipodi:absref instead of the xlink:href value,
* then we should do `if streq() { free them and set both to NULL; }'. */
}
- sp_repr_save_stream(doc, file, default_ns, compress, old_href_abs_base.c_str(), new_href_abs_base);
-
- g_free(new_href_abs_base);
+ sp_repr_save_stream(doc, file, default_ns, compress, old_href_abs_base.c_str(), new_href_abs_base.c_str());
if (fclose (file) != 0) {
return false;