From a7f2b2ba3f13ceb60376802f4a31e104153839e8 Mon Sep 17 00:00:00 2001 From: Marc Jeanmougin Date: Tue, 17 Feb 2015 03:00:37 +0100 Subject: At first, I was thinking "I just have to go to the selection file, and change that GSList* with a std::list, then resolve the few problems" So, i tried that. And I will continue tomorrow, and the days after, on and on. (bzr r13922.1.1) --- src/ui/dialog/export.cpp | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'src/ui/dialog/export.cpp') diff --git a/src/ui/dialog/export.cpp b/src/ui/dialog/export.cpp index 6d90c792e..fc6094c9f 100644 --- a/src/ui/dialog/export.cpp +++ b/src/ui/dialog/export.cpp @@ -605,7 +605,7 @@ void Export::onBatchClicked () void Export::updateCheckbuttons () { - gint num = g_slist_length((GSList *) SP_ACTIVE_DESKTOP->getSelection()->itemList()); + gint num = SP_ACTIVE_DESKTOP->getSelection()->itemList().size(); if (num >= 2) { batch_export.set_sensitive(true); batch_export.set_label(g_strdup_printf (ngettext("B_atch export %d selected object","B_atch export %d selected objects",num), num)); @@ -817,9 +817,9 @@ void Export::onAreaToggled () one that's nice */ if (filename.empty()) { const gchar * id = "object"; - const GSList * reprlst = SP_ACTIVE_DESKTOP->getSelection()->reprList(); - for(; reprlst != NULL; reprlst = reprlst->next) { - Inkscape::XML::Node * repr = (Inkscape::XML::Node *)reprlst->data; + const SelContainer reprlst = SP_ACTIVE_DESKTOP->getSelection()->reprList(); + for(SelContainer::const_iterator i=reprlst.begin(); reprlst.end() != i; i++) { + Inkscape::XML::Node * repr = (Inkscape::XML::Node *)(*i); if (repr->attribute("id")) { id = repr->attribute("id"); break; @@ -1010,7 +1010,7 @@ void Export::onExport () if (batch_export.get_active ()) { // Batch export of selected objects - gint num = g_slist_length(const_cast(desktop->getSelection()->itemList())); + gint num = (desktop->getSelection()->itemList()).size(); gint n = 0; if (num < 1) { @@ -1024,8 +1024,9 @@ void Export::onExport () gint export_count = 0; - for (GSList *i = const_cast(desktop->getSelection()->itemList()); i && !interrupted; i = i->next) { - SPItem *item = reinterpret_cast(i->data); + SelContainer itemlist=desktop->getSelection()->itemList(); + for(SelContainer::const_iterator i = itemlist.begin();i!=itemlist.end() && !interrupted ;i++){ + SPItem *item = reinterpret_cast(*i); prog_dlg->set_data("current", GINT_TO_POINTER(n)); prog_dlg->set_data("total", GINT_TO_POINTER(num)); @@ -1063,13 +1064,13 @@ void Export::onExport () _("Exporting file %s..."), safeFile), desktop); MessageCleaner msgFlashCleanup(desktop->messageStack()->flashF(Inkscape::IMMEDIATE_MESSAGE, _("Exporting file %s..."), safeFile), desktop); - + SelContainer x; if (!sp_export_png_file (doc, path.c_str(), *area, width, height, dpi, dpi, nv->pagecolor, onProgressCallback, (void*)prog_dlg, TRUE, // overwrite without asking - hide ? const_cast(desktop->getSelection()->itemList()) : NULL + hide ? (desktop->getSelection()->itemList()) : x )) { gchar * error = g_strdup_printf(_("Could not export to filename %s.\n"), safeFile); @@ -1153,12 +1154,13 @@ void Export::onExport () prog_dlg->set_data("total", GINT_TO_POINTER(0)); /* Do export */ + SelContainer x; ExportResult status = sp_export_png_file(desktop->getDocument(), path.c_str(), Geom::Rect(Geom::Point(x0, y0), Geom::Point(x1, y1)), width, height, xdpi, ydpi, nv->pagecolor, onProgressCallback, (void*)prog_dlg, FALSE, - hide ? const_cast(desktop->getSelection()->itemList()) : NULL + hide ? (desktop->getSelection()->itemList()) : x ); if (status == EXPORT_ERROR) { gchar * safeFile = Inkscape::IO::sanitizeString(path.c_str()); @@ -1224,7 +1226,7 @@ void Export::onExport () break; } case SELECTION_SELECTION: { - const GSList * reprlst; + SelContainer reprlst; SPDocument * doc = SP_ACTIVE_DOCUMENT; bool modified = false; @@ -1232,8 +1234,8 @@ void Export::onExport () DocumentUndo::setUndoSensitive(doc, false); reprlst = desktop->getSelection()->reprList(); - for(; reprlst != NULL; reprlst = reprlst->next) { - Inkscape::XML::Node * repr = static_cast(reprlst->data); + for(SelContainer::const_iterator i=reprlst.begin(); reprlst.end() != i; i++) { + Inkscape::XML::Node * repr = dynamic_cast(*i); const gchar * temp_string; Glib::ustring dir = Glib::path_get_dirname(filename.c_str()); const gchar* docURI=SP_ACTIVE_DOCUMENT->getURI(); -- cgit v1.2.3 From 9e21d00fb1053897420f80d05a9815c5b2bbf312 Mon Sep 17 00:00:00 2001 From: mc <> Date: Wed, 18 Feb 2015 11:25:23 +0100 Subject: I can't really understand why, but i can now launch inkscape without it segfaulting. That's an improvement. Next thing: code cleaning, replacing containers with vectors (bzr r13922.1.4) --- src/ui/dialog/export.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/ui/dialog/export.cpp') diff --git a/src/ui/dialog/export.cpp b/src/ui/dialog/export.cpp index fc6094c9f..0667ba721 100644 --- a/src/ui/dialog/export.cpp +++ b/src/ui/dialog/export.cpp @@ -817,9 +817,9 @@ void Export::onAreaToggled () one that's nice */ if (filename.empty()) { const gchar * id = "object"; - const SelContainer reprlst = SP_ACTIVE_DESKTOP->getSelection()->reprList(); - for(SelContainer::const_iterator i=reprlst.begin(); reprlst.end() != i; i++) { - Inkscape::XML::Node * repr = (Inkscape::XML::Node *)(*i); + const std::vector reprlst = SP_ACTIVE_DESKTOP->getSelection()->reprList(); + for(std::vector::const_iterator i=reprlst.begin(); reprlst.end() != i; i++) { + Inkscape::XML::Node * repr = (*i); if (repr->attribute("id")) { id = repr->attribute("id"); break; @@ -1226,7 +1226,7 @@ void Export::onExport () break; } case SELECTION_SELECTION: { - SelContainer reprlst; + std::vector reprlst; SPDocument * doc = SP_ACTIVE_DOCUMENT; bool modified = false; @@ -1234,8 +1234,8 @@ void Export::onExport () DocumentUndo::setUndoSensitive(doc, false); reprlst = desktop->getSelection()->reprList(); - for(SelContainer::const_iterator i=reprlst.begin(); reprlst.end() != i; i++) { - Inkscape::XML::Node * repr = dynamic_cast(*i); + for(std::vector::const_iterator i=reprlst.begin(); reprlst.end() != i; i++) { + Inkscape::XML::Node * repr = *i; const gchar * temp_string; Glib::ustring dir = Glib::path_get_dirname(filename.c_str()); const gchar* docURI=SP_ACTIVE_DOCUMENT->getURI(); -- cgit v1.2.3 From 5fd00cab14d48beaf2279a2b8f3ad5b02b76c87b Mon Sep 17 00:00:00 2001 From: Marc Jeanmougin Date: Thu, 19 Feb 2015 04:25:21 +0100 Subject: Put a few std::vector (bzr r13922.1.5) --- src/ui/dialog/export.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/ui/dialog/export.cpp') diff --git a/src/ui/dialog/export.cpp b/src/ui/dialog/export.cpp index 0667ba721..32eed088c 100644 --- a/src/ui/dialog/export.cpp +++ b/src/ui/dialog/export.cpp @@ -1024,8 +1024,8 @@ void Export::onExport () gint export_count = 0; - SelContainer itemlist=desktop->getSelection()->itemList(); - for(SelContainer::const_iterator i = itemlist.begin();i!=itemlist.end() && !interrupted ;i++){ + std::vector itemlist=desktop->getSelection()->itemList(); + for(std::vector::const_iterator i = itemlist.begin();i!=itemlist.end() && !interrupted ;i++){ SPItem *item = reinterpret_cast(*i); prog_dlg->set_data("current", GINT_TO_POINTER(n)); @@ -1064,7 +1064,7 @@ void Export::onExport () _("Exporting file %s..."), safeFile), desktop); MessageCleaner msgFlashCleanup(desktop->messageStack()->flashF(Inkscape::IMMEDIATE_MESSAGE, _("Exporting file %s..."), safeFile), desktop); - SelContainer x; + std::vector x; if (!sp_export_png_file (doc, path.c_str(), *area, width, height, dpi, dpi, nv->pagecolor, @@ -1154,7 +1154,7 @@ void Export::onExport () prog_dlg->set_data("total", GINT_TO_POINTER(0)); /* Do export */ - SelContainer x; + std::vector x; ExportResult status = sp_export_png_file(desktop->getDocument(), path.c_str(), Geom::Rect(Geom::Point(x0, y0), Geom::Point(x1, y1)), width, height, xdpi, ydpi, nv->pagecolor, -- cgit v1.2.3 From 9a7fa4d1899d30ec745107823f307b2a0bf3172f Mon Sep 17 00:00:00 2001 From: Marc Jeanmougin Date: Fri, 27 Feb 2015 03:10:36 +0100 Subject: corrected the casts (hopefully) (bzr r13922.1.10) --- src/ui/dialog/export.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/ui/dialog/export.cpp') diff --git a/src/ui/dialog/export.cpp b/src/ui/dialog/export.cpp index 32eed088c..ca3971019 100644 --- a/src/ui/dialog/export.cpp +++ b/src/ui/dialog/export.cpp @@ -819,7 +819,7 @@ void Export::onAreaToggled () const gchar * id = "object"; const std::vector reprlst = SP_ACTIVE_DESKTOP->getSelection()->reprList(); for(std::vector::const_iterator i=reprlst.begin(); reprlst.end() != i; i++) { - Inkscape::XML::Node * repr = (*i); + Inkscape::XML::Node * repr = *i; if (repr->attribute("id")) { id = repr->attribute("id"); break; @@ -1026,7 +1026,7 @@ void Export::onExport () std::vector itemlist=desktop->getSelection()->itemList(); for(std::vector::const_iterator i = itemlist.begin();i!=itemlist.end() && !interrupted ;i++){ - SPItem *item = reinterpret_cast(*i); + SPItem *item = *i; prog_dlg->set_data("current", GINT_TO_POINTER(n)); prog_dlg->set_data("total", GINT_TO_POINTER(num)); -- cgit v1.2.3 From ba4dbfb351180e0fc4ad57be6e3534fa2ab5cf8c Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Tue, 28 Apr 2015 00:38:31 +0100 Subject: Fix unnecessary inclusion of glibmm/threads.h. This can be resolved by ensuring that glibmm headers always preceed glib.h headers. Same applies with gtkmm/gtk+ etc (bzr r14064) --- src/ui/dialog/export.cpp | 4 ---- 1 file changed, 4 deletions(-) (limited to 'src/ui/dialog/export.cpp') diff --git a/src/ui/dialog/export.cpp b/src/ui/dialog/export.cpp index 6d90c792e..9ac5c24fe 100644 --- a/src/ui/dialog/export.cpp +++ b/src/ui/dialog/export.cpp @@ -20,10 +20,6 @@ // This has to be included prior to anything that includes setjmp.h, it croaks otherwise #include -#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H -#include -#endif - #include #include #include -- cgit v1.2.3