summaryrefslogtreecommitdiffstats
path: root/src/extension
diff options
context:
space:
mode:
authorjabiertxof <jabiertxof@debian.marker.es>2015-04-29 14:33:09 +0000
committerjabiertxof <jabiertxof@debian.marker.es>2015-04-29 14:33:09 +0000
commitcd2a40d327c536e12dd113a0c8c2fe5038affe48 (patch)
tree7e8c12e63848a90246f591067244f6891fd70336 /src/extension
parentFis fix a bug finded in my presentation in the HackFest (diff)
parentIncrease precision (long thin paths had a ton of width variance), fix logic e... (diff)
downloadinkscape-cd2a40d327c536e12dd113a0c8c2fe5038affe48.tar.gz
inkscape-cd2a40d327c536e12dd113a0c8c2fe5038affe48.zip
update to trunk
(bzr r12588.1.44)
Diffstat (limited to 'src/extension')
-rw-r--r--src/extension/execution-env.cpp4
-rw-r--r--src/extension/extension.cpp4
-rw-r--r--src/extension/implementation/script.cpp5
-rw-r--r--src/extension/implementation/script.h2
-rw-r--r--src/extension/internal/bitmap/imagemagick.cpp4
-rw-r--r--src/extension/internal/cdr-input.h4
-rw-r--r--src/extension/internal/emf-inout.cpp50
-rw-r--r--src/extension/internal/emf-inout.h2
-rw-r--r--src/extension/internal/emf-print.cpp12
-rw-r--r--src/extension/internal/grid.cpp4
-rw-r--r--src/extension/internal/pdfinput/pdf-input.h4
-rw-r--r--src/extension/internal/vsd-input.h4
-rw-r--r--src/extension/internal/wmf-inout.cpp68
-rw-r--r--src/extension/internal/wmf-print.cpp6
-rw-r--r--src/extension/param/bool.cpp4
-rw-r--r--src/extension/param/color.cpp4
-rw-r--r--src/extension/param/description.cpp4
-rw-r--r--src/extension/param/enum.cpp4
-rw-r--r--src/extension/param/float.cpp4
-rw-r--r--src/extension/param/int.cpp4
-rw-r--r--src/extension/param/notebook.cpp4
-rw-r--r--src/extension/param/radiobutton.cpp4
-rw-r--r--src/extension/param/string.cpp4
-rw-r--r--src/extension/prefdialog.h9
24 files changed, 97 insertions, 121 deletions
diff --git a/src/extension/execution-env.cpp b/src/extension/execution-env.cpp
index 13b8d60c4..e7cd43d9d 100644
--- a/src/extension/execution-env.cpp
+++ b/src/extension/execution-env.cpp
@@ -14,10 +14,6 @@
# include <config.h>
#endif
-#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H
-#include <glibmm/threads.h>
-#endif
-
#include "gtkmm/messagedialog.h"
#include "execution-env.h"
diff --git a/src/extension/extension.cpp b/src/extension/extension.cpp
index 3d0f49a20..6f7539360 100644
--- a/src/extension/extension.cpp
+++ b/src/extension/extension.cpp
@@ -19,10 +19,6 @@
# include "config.h"
#endif
-#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H
-#include <glibmm/threads.h>
-#endif
-
#include <gtkmm/box.h>
#include <gtkmm/label.h>
#include <gtkmm/frame.h>
diff --git a/src/extension/implementation/script.cpp b/src/extension/implementation/script.cpp
index bbc567f75..52c360fcd 100644
--- a/src/extension/implementation/script.cpp
+++ b/src/extension/implementation/script.cpp
@@ -1027,7 +1027,10 @@ int Script::execute (const std::list<std::string> &in_command,
return 0;
}
- _main_loop = Glib::MainLoop::create(false);
+ // Create a new MainContext for the loop so that the original context sources are not run here,
+ // this enforces that only the file_listeners should be read in this new MainLoop
+ Glib::RefPtr<Glib::MainContext> _main_context = Glib::MainContext::create();
+ _main_loop = Glib::MainLoop::create(_main_context, false);
file_listener fileerr;
fileout.init(stdout_pipe, _main_loop);
diff --git a/src/extension/implementation/script.h b/src/extension/implementation/script.h
index 6a7d0c3b8..4cf33c989 100644
--- a/src/extension/implementation/script.h
+++ b/src/extension/implementation/script.h
@@ -90,7 +90,7 @@ private:
void init (int fd, Glib::RefPtr<Glib::MainLoop> main) {
_channel = Glib::IOChannel::create_from_fd(fd);
_channel->set_encoding();
- _conn = Glib::signal_io().connect(sigc::mem_fun(*this, &file_listener::read), _channel, Glib::IO_IN | Glib::IO_HUP | Glib::IO_ERR);
+ _conn = main->get_context()->signal_io().connect(sigc::mem_fun(*this, &file_listener::read), _channel, Glib::IO_IN | Glib::IO_HUP | Glib::IO_ERR);
_main_loop = main;
return;
diff --git a/src/extension/internal/bitmap/imagemagick.cpp b/src/extension/internal/bitmap/imagemagick.cpp
index 76f35415e..7c91bf1ef 100644
--- a/src/extension/internal/bitmap/imagemagick.cpp
+++ b/src/extension/internal/bitmap/imagemagick.cpp
@@ -12,10 +12,6 @@
# include "config.h"
#endif
-#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H
-#include <glibmm/threads.h>
-#endif
-
#include <libintl.h>
#include <gtkmm/box.h>
diff --git a/src/extension/internal/cdr-input.h b/src/extension/internal/cdr-input.h
index 3de6c1ed0..10af41d5a 100644
--- a/src/extension/internal/cdr-input.h
+++ b/src/extension/internal/cdr-input.h
@@ -19,10 +19,6 @@
#ifdef WITH_LIBCDR
-#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H
-#include <glibmm/threads.h>
-#endif
-
#include <gtkmm/dialog.h>
#include "../implementation/implementation.h"
diff --git a/src/extension/internal/emf-inout.cpp b/src/extension/internal/emf-inout.cpp
index 31e69706f..e88cf3d42 100644
--- a/src/extension/internal/emf-inout.cpp
+++ b/src/extension/internal/emf-inout.cpp
@@ -480,7 +480,7 @@ uint32_t Emf::add_image(PEMF_CALLBACK_DATA d, void *pEmr, uint32_t cbBits, uint
uint32_t width, height, colortype, numCt, invert; // if needed these values will be set in get_DIB_params
if(cbBits && cbBmi && (iUsage == U_DIB_RGB_COLORS)){
// next call returns pointers and values, but allocates no memory
- dibparams = get_DIB_params(pEmr, offBits, offBmi, &px, (const U_RGBQUAD **) &ct,
+ dibparams = get_DIB_params((const char *)pEmr, offBits, offBmi, &px, (const U_RGBQUAD **) &ct,
&numCt, &width, &height, &colortype, &invert);
if(dibparams ==U_BI_RGB){
// U_EMRCREATEMONOBRUSH uses text/bk colors instead of what is in the color map.
@@ -1307,7 +1307,7 @@ Emf::select_extpen(PEMF_CALLBACK_DATA d, int index)
d->dc[d->level].stroke_set = true;
}
else if(pEmr->elp.elpBrushStyle == U_BS_DIBPATTERN || pEmr->elp.elpBrushStyle == U_BS_DIBPATTERNPT){
- d->dc[d->level].stroke_idx = add_image(d, pEmr, pEmr->cbBits, pEmr->cbBmi, *(uint32_t *) &(pEmr->elp.elpColor), pEmr->offBits, pEmr->offBmi);
+ d->dc[d->level].stroke_idx = add_image(d, (void *)pEmr, pEmr->cbBits, pEmr->cbBmi, *(uint32_t *) &(pEmr->elp.elpColor), pEmr->offBits, pEmr->offBmi);
d->dc[d->level].stroke_mode = DRAW_IMAGE;
d->dc[d->level].stroke_set = true;
}
@@ -1530,7 +1530,7 @@ void Emf::common_image_extraction(PEMF_CALLBACK_DATA d, void *pEmr,
uint32_t width, height, colortype, numCt, invert; // if needed these values will be set in get_DIB_params
if(cbBits && cbBmi && (iUsage == U_DIB_RGB_COLORS)){
// next call returns pointers and values, but allocates no memory
- dibparams = get_DIB_params(pEmr, offBits, offBmi, &px, (const U_RGBQUAD **) &ct,
+ dibparams = get_DIB_params((const char *)pEmr, offBits, offBmi, &px, (const U_RGBQUAD **) &ct,
&numCt, &width, &height, &colortype, &invert);
if(dibparams ==U_BI_RGB){
if(sw == 0 || sh == 0){
@@ -1611,6 +1611,10 @@ int Emf::myEnhMetaFileProc(char *contents, unsigned int length, PEMF_CALLBACK_DA
uint32_t off=0;
uint32_t emr_mask;
int OK =1;
+ int file_status=1;
+ uint32_t nSize;
+ uint32_t iType;
+ const char *blimit = contents + length;
PU_ENHMETARECORD lpEMFR;
TCHUNK_SPECS tsp;
uint32_t tbkMode = U_TRANSPARENT; // holds proposed change to bkMode, if text is involved saving these to the DC must wait until the text is written
@@ -1641,19 +1645,32 @@ int Emf::myEnhMetaFileProc(char *contents, unsigned int length, PEMF_CALLBACK_DA
while(OK){
if(off>=length)return(0); //normally should exit from while after EMREOF sets OK to false.
+ // check record sizes and types thoroughly
+ int badrec = 0;
+ if (!U_emf_record_sizeok(contents + off, blimit, &nSize, &iType, 1) ||
+ !U_emf_record_safe(contents + off)){
+ badrec = 1;
+ }
+ else {
+ emr_mask = emr_properties(iType);
+ if (emr_mask == U_EMR_INVALID) { badrec = 1; }
+ }
+ if (badrec) {
+ file_status = 0;
+ break;
+ }
+
lpEMFR = (PU_ENHMETARECORD)(contents + off);
+
// Uncomment the following to track down toxic records
-// std::cout << "record type: " << lpEMFR->iType << " name " << U_emr_names(lpEMFR->iType) << " length: " << lpEMFR->nSize << " offset: " << off <<std::endl;
- off += lpEMFR->nSize;
+// std::cout << "record type: " << iType << " name " << U_emr_names(iType) << " length: " << nSize << " offset: " << off <<std::endl;
+ off += nSize;
SVGOStringStream tmp_outsvg;
SVGOStringStream tmp_path;
SVGOStringStream tmp_str;
SVGOStringStream dbg_str;
- emr_mask = emr_properties(lpEMFR->iType);
- if(emr_mask == U_EMR_INVALID){ throw "Inkscape fatal memory allocation error - cannot continue"; }
-
/* Uncomment the following to track down text problems */
//std::cout << "tri->dirty:"<< d->tri->dirty << " emr_mask: " << std::hex << emr_mask << std::dec << std::endl;
@@ -1753,7 +1770,7 @@ std::cout << "BEFORE DRAW"
}
// std::cout << "AFTER DRAW logic d->mask: " << std::hex << d->mask << " emr_mask: " << emr_mask << std::dec << std::endl;
- switch (lpEMFR->iType)
+ switch (iType)
{
case U_EMR_HEADER:
{
@@ -3471,7 +3488,7 @@ std::cout << "BEFORE DRAW"
// std::cout << d->outsvg << std::endl;
(void) emr_properties(U_EMR_INVALID); // force the release of the lookup table memory, returned value is irrelevant
- return 1;
+ return(file_status);
}
void Emf::free_emf_strings(EMF_STRINGS name){
@@ -3486,12 +3503,14 @@ void Emf::free_emf_strings(EMF_STRINGS name){
SPDocument *
Emf::open( Inkscape::Extension::Input * /*mod*/, const gchar *uri )
{
- EMF_CALLBACK_DATA d;
-
if (uri == NULL) {
return NULL;
}
+ EMF_CALLBACK_DATA d;
+
+ d.n_obj = 0; //these might not be set otherwise if the input file is corrupt
+ d.emf_obj = NULL;
d.dc[0].font_name = strdup("Arial"); // Default font, set only on lowest level, it copies up from there EMF spec says device can pick whatever it wants
// set up the size default for patterns in defs. This might not be referenced if there are no patterns defined in the drawing.
@@ -3518,14 +3537,17 @@ Emf::open( Inkscape::Extension::Input * /*mod*/, const gchar *uri )
FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP,
FT_KERNING_UNSCALED);
- (void) myEnhMetaFileProc(contents,length, &d);
+ int good = myEnhMetaFileProc(contents,length, &d);
free(contents);
if (d.pDesc){ free( d.pDesc ); }
// std::cout << "SVG Output: " << std::endl << d.outsvg << std::endl;
- SPDocument *doc = SPDocument::createNewDocFromMem(d.outsvg.c_str(), strlen(d.outsvg.c_str()), TRUE);
+ SPDocument *doc = NULL;
+ if (good) {
+ doc = SPDocument::createNewDocFromMem(d.outsvg.c_str(), strlen(d.outsvg.c_str()), TRUE);
+ }
free_emf_strings(d.hatches);
free_emf_strings(d.images);
diff --git a/src/extension/internal/emf-inout.h b/src/extension/internal/emf-inout.h
index c64299093..dd1d8f9c4 100644
--- a/src/extension/internal/emf-inout.h
+++ b/src/extension/internal/emf-inout.h
@@ -13,6 +13,8 @@
#define SEEN_EXTENSION_INTERNAL_EMF_H
#include <libuemf/uemf.h>
+#include <libuemf/uemf_safe.h>
+#include <libuemf/uemf_endian.h> // for U_emf_record_sizeok()
#include "extension/internal/metafile-inout.h" // picks up PNG
#include "extension/implementation/implementation.h"
#include "style.h"
diff --git a/src/extension/internal/emf-print.cpp b/src/extension/internal/emf-print.cpp
index 67a9242bc..ed3ae158a 100644
--- a/src/extension/internal/emf-print.cpp
+++ b/src/extension/internal/emf-print.cpp
@@ -60,6 +60,7 @@
#include "splivarot.h" // pieces for union on shapes
#include "2geom/svg-path-parser.h" // to get from SVG text to Geom::Path
#include "display/canvas-bpath.h" // for SPWindRule
+#include "display/cairo-utils.h" // for Inkscape::Pixbuf::PF_CAIRO
#include "emf-print.h"
@@ -70,7 +71,6 @@ namespace Internal {
#define PXPERMETER 2835
-
/* globals */
static double PX2WORLD;
static bool FixPPTCharPos, FixPPTDashLine, FixPPTGrad2Polys, FixPPTLinGrad, FixPPTPatternAsHatch, FixImageRot;
@@ -481,9 +481,8 @@ int PrintEmf::create_brush(SPStyle const *style, PU_COLORREF fcolor)
rgba_px = (char *) pixbuf->pixels(); // Do NOT free this!!!
colortype = U_BCBM_COLOR32;
(void) RGBA_to_DIB(&px, &cbPx, &ct, &numCt, rgba_px, width, height, width * 4, colortype, 0, 1);
- // Not sure why the next swap is needed because the preceding does it, and the code is identical
- // to that in stretchdibits_set, which does not need this.
- swapRBinRGBA(px, width * height);
+ // pixbuf can be either PF_CAIRO or PF_GDK, and these have R and B bytes swapped
+ if (pixbuf->pixelFormat() == Inkscape::Pixbuf::PF_CAIRO) { swapRBinRGBA(px, width * height); }
Bmih = bitmapinfoheader_set(width, height, 1, colortype, U_BI_RGB, 0, PXPERMETER, PXPERMETER, numCt, 0);
Bmi = bitmapinfo_set(Bmih, ct);
rec = createdibpatternbrushpt_set(&brush, eht, U_DIB_RGB_COLORS, Bmi, cbPx, px);
@@ -584,9 +583,8 @@ int PrintEmf::create_pen(SPStyle const *style, const Geom::Affine &transform)
rgba_px = (char *) pixbuf->pixels(); // Do NOT free this!!!
colortype = U_BCBM_COLOR32;
(void) RGBA_to_DIB(&px, &cbPx, &ct, &numCt, rgba_px, width, height, width * 4, colortype, 0, 1);
- // Not sure why the next swap is needed because the preceding does it, and the code is identical
- // to that in stretchdibits_set, which does not need this.
- swapRBinRGBA(px, width * height);
+ // pixbuf can be either PF_CAIRO or PF_GDK, and these have R and B bytes swapped
+ if (pixbuf->pixelFormat() == Inkscape::Pixbuf::PF_CAIRO) { swapRBinRGBA(px, width * height); }
Bmih = bitmapinfoheader_set(width, height, 1, colortype, U_BI_RGB, 0, PXPERMETER, PXPERMETER, numCt, 0);
Bmi = bitmapinfo_set(Bmih, ct);
} else { // pattern
diff --git a/src/extension/internal/grid.cpp b/src/extension/internal/grid.cpp
index 270edfe44..61f2f70e2 100644
--- a/src/extension/internal/grid.cpp
+++ b/src/extension/internal/grid.cpp
@@ -15,10 +15,6 @@
# include <config.h>
#endif
-#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H
-#include <glibmm/threads.h>
-#endif
-
#include <gtkmm/box.h>
#include <gtkmm/adjustment.h>
#include <gtkmm/spinbutton.h>
diff --git a/src/extension/internal/pdfinput/pdf-input.h b/src/extension/internal/pdfinput/pdf-input.h
index d57c3e993..866db5d82 100644
--- a/src/extension/internal/pdfinput/pdf-input.h
+++ b/src/extension/internal/pdfinput/pdf-input.h
@@ -16,10 +16,6 @@
#ifdef HAVE_POPPLER
-#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H
-#include <glibmm/threads.h>
-#endif
-
#include <gtkmm/dialog.h>
#include "../../implementation/implementation.h"
diff --git a/src/extension/internal/vsd-input.h b/src/extension/internal/vsd-input.h
index 3414e0ec9..acc52debf 100644
--- a/src/extension/internal/vsd-input.h
+++ b/src/extension/internal/vsd-input.h
@@ -19,10 +19,6 @@
#ifdef WITH_LIBVISIO
-#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H
-#include <glibmm/threads.h>
-#endif
-
#include <gtkmm/dialog.h>
#include "../implementation/implementation.h"
diff --git a/src/extension/internal/wmf-inout.cpp b/src/extension/internal/wmf-inout.cpp
index 503a93418..3ab7a4e89 100644
--- a/src/extension/internal/wmf-inout.cpp
+++ b/src/extension/internal/wmf-inout.cpp
@@ -1497,6 +1497,7 @@ int Wmf::myMetaFileProc(const char *contents, unsigned int length, PWMF_CALLBACK
uint32_t off=0;
uint32_t wmr_mask;
int OK =1;
+ int file_status=1;
TCHUNK_SPECS tsp;
uint8_t iType;
int nSize; // size of the current record, in bytes, or an error value if <=0
@@ -1562,7 +1563,9 @@ int Wmf::myMetaFileProc(const char *contents, unsigned int length, PWMF_CALLBACK
U_WMRHEADER Header;
off = 0;
nSize = wmfheader_get(contents, blimit, &Placeable, &Header);
- if(!nSize)return(0);
+ if (!nSize) {
+ return(0);
+ }
if(!Header.nObjects){ Header.nObjects = 256; }// there _may_ be WMF files with no objects, more likely it is corrupt. Try to use it anyway.
d->n_obj = Header.nObjects;
d->wmf_obj = new WMF_OBJECT[d->n_obj];
@@ -1602,7 +1605,10 @@ int Wmf::myMetaFileProc(const char *contents, unsigned int length, PWMF_CALLBACK
else {
off += nSize;
}
- }
+ }
+ else {
+ return(0);
+ }
}
off=0;
nSize = hold_nSize;
@@ -1665,27 +1671,32 @@ int Wmf::myMetaFileProc(const char *contents, unsigned int length, PWMF_CALLBACK
while(OK){
- if(off>=length)return(0); //normally should exit from while after WMREOF sets OK to false.
+ if (off>=length) {
+ return(0); //normally should exit from while after WMREOF sets OK to false.
+ }
contents += nSize; // pointer to the start of the next record
off += nSize; // offset from beginning of buffer to the start of the next record
- SVGOStringStream tmp_path;
- SVGOStringStream tmp_str;
-
- /* Check that the current record size is OK, abort if not.
- Pointer math might wrap, so check both sides of the range.
- Some of the records will reset this with the same value,others will not
- return a value at this time. */
+ /* Currently this is a weaker check than for EMF, it only checks the size of the constant part
+ of the record */
nSize = U_WMRRECSAFE_get(contents, blimit);
- if(!nSize)break;
+ if(!nSize) {
+ file_status = 0;
+ break;
+ }
iType = *(uint8_t *)(contents + offsetof(U_METARECORD, iType ) );
+ wmr_mask = U_wmr_properties(iType);
+ if (wmr_mask == U_WMR_INVALID) {
+ file_status = 0;
+ break;
+ }
// Uncomment the following to track down toxic records
// std::cout << "record type: " << (int) iType << " name " << U_wmr_names(iType) << " length: " << nSize << " offset: " << off <<std::endl;
- wmr_mask = U_wmr_properties(iType);
- if(wmr_mask == U_WMR_INVALID){ throw "Inkscape fatal programming error at U_wmr_properties"; }
+ SVGOStringStream tmp_path;
+ SVGOStringStream tmp_str;
/* Uncomment the following to track down text problems */
//std::cout << "tri->dirty:"<< d->tri->dirty << " wmr_mask: " << std::hex << wmr_mask << std::dec << std::endl;
@@ -3026,14 +3037,17 @@ std::cout << "BEFORE DRAW"
// When testing, uncomment the following to place a comment for each processed WMR record in the SVG
// d->outsvg += dbg_str.str().c_str();
d->path += tmp_path.str().c_str();
- if(!nSize){ OK=0; std::cout << "nSize == 0, oops!!!" << std::endl; } // There was some problem with this record, it is not safe to continue
+ if(!nSize){ // There was some problem with the processing of this record, it is not safe to continue
+ file_status = 0;
+ break;
+ }
- } //end of while
+ } //end of while on OK
// When testing, uncomment the following to show the final SVG derived from the WMF
// std::cout << d->outsvg << std::endl;
(void) U_wmr_properties(U_WMR_INVALID); // force the release of the lookup table memory, returned value is irrelevant
- return 1;
+ return(file_status);
}
void Wmf::free_wmf_strings(WMF_STRINGS name){
@@ -3049,7 +3063,14 @@ SPDocument *
Wmf::open( Inkscape::Extension::Input * /*mod*/, const gchar *uri )
{
+ if (uri == NULL) {
+ return NULL;
+ }
+
WMF_CALLBACK_DATA d;
+
+ d.n_obj = 0; //these might not be set otherwise if the input file is corrupt
+ d.wmf_obj=NULL;
// Default font, WMF spec says device can pick whatever it wants.
// WMF files that do not specify a font are unlikely to look very good!
@@ -3064,12 +3085,12 @@ Wmf::open( Inkscape::Extension::Input * /*mod*/, const gchar *uri )
d.dc[0].style.stroke_dasharray.set = 0;
d.dc[0].style.stroke_linecap.computed = 2; // U_PS_ENDCAP_SQUARE;
d.dc[0].style.stroke_linejoin.computed = 0; // U_PS_JOIN_MITER;
- d.dc[0].style.stroke_width.value = 1.0; // will be reset to something reasonable once WMF draying size is known
+ d.dc[0].style.stroke_width.value = 1.0; // will be reset to something reasonable once WMF drawing size is known
d.dc[0].style.stroke.value.color.set( 0, 0, 0 );
+ d.dc[0].stroke_set = true;
- if (uri == NULL) {
- return NULL;
- }
+ // Default brush is none - no fill. WMF files that do not specify a brush are unlikely to look very good!
+ d.dc[0].fill_set = false;
d.dc[0].font_name = strdup("Arial"); // Default font, set only on lowest level, it copies up from there WMF spec says device can pick whatever it wants
@@ -3095,12 +3116,15 @@ Wmf::open( Inkscape::Extension::Input * /*mod*/, const gchar *uri )
FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP,
FT_KERNING_UNSCALED);
- (void) myMetaFileProc(contents,length, &d);
+ int good = myMetaFileProc(contents,length, &d);
free(contents);
// std::cout << "SVG Output: " << std::endl << d.outsvg << std::endl;
- SPDocument *doc = SPDocument::createNewDocFromMem(d.outsvg.c_str(), strlen(d.outsvg.c_str()), TRUE);
+ SPDocument *doc = NULL;
+ if (good) {
+ doc = SPDocument::createNewDocFromMem(d.outsvg.c_str(), strlen(d.outsvg.c_str()), TRUE);
+ }
free_wmf_strings(d.hatches);
free_wmf_strings(d.images);
diff --git a/src/extension/internal/wmf-print.cpp b/src/extension/internal/wmf-print.cpp
index 567f9f366..9fe1a0259 100644
--- a/src/extension/internal/wmf-print.cpp
+++ b/src/extension/internal/wmf-print.cpp
@@ -61,6 +61,7 @@
#include "splivarot.h" // pieces for union on shapes
#include "2geom/svg-path-parser.h" // to get from SVG text to Geom::Path
#include "display/canvas-bpath.h" // for SPWindRule
+#include "display/cairo-utils.h" // for Inkscape::Pixbuf::PF_CAIRO
#include "wmf-print.h"
@@ -471,9 +472,8 @@ int PrintWmf::create_brush(SPStyle const *style, U_COLORREF *fcolor)
rgba_px = (char *) pixbuf->pixels(); // Do NOT free this!!!
colortype = U_BCBM_COLOR32;
(void) RGBA_to_DIB(&px, &cbPx, &ct, &numCt, rgba_px, width, height, width * 4, colortype, 0, 1);
- // Not sure why the next swap is needed because the preceding does it, and the code is identical
- // to that in stretchdibits_set, which does not need this.
- swapRBinRGBA(px, width * height);
+ // pixbuf can be either PF_CAIRO or PF_GDK, and these have R and B bytes swapped
+ if (pixbuf->pixelFormat() == Inkscape::Pixbuf::PF_CAIRO) { swapRBinRGBA(px, width * height); }
Bmih = bitmapinfoheader_set(width, height, 1, colortype, U_BI_RGB, 0, PXPERMETER, PXPERMETER, numCt, 0);
Bmi = bitmapinfo_set(Bmih, ct);
rec = wcreatedibpatternbrush_srcdib_set(&brush, wht, U_DIB_RGB_COLORS, Bmi, cbPx, px);
diff --git a/src/extension/param/bool.cpp b/src/extension/param/bool.cpp
index 548dec4fa..de9b1c586 100644
--- a/src/extension/param/bool.cpp
+++ b/src/extension/param/bool.cpp
@@ -10,10 +10,6 @@
# include "config.h"
#endif
-#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H
-#include <glibmm/threads.h>
-#endif
-
#include <gtkmm/adjustment.h>
#include <gtkmm/box.h>
#include <gtkmm/spinbutton.h>
diff --git a/src/extension/param/color.cpp b/src/extension/param/color.cpp
index 5bd70359f..b774bac83 100644
--- a/src/extension/param/color.cpp
+++ b/src/extension/param/color.cpp
@@ -14,10 +14,6 @@
#include <iostream>
#include <sstream>
-#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H
-#include <glibmm/threads.h>
-#endif
-
#include <gtkmm/adjustment.h>
#include <gtkmm/box.h>
#include <gtkmm/spinbutton.h>
diff --git a/src/extension/param/description.cpp b/src/extension/param/description.cpp
index 95ed04afc..326e75e4a 100644
--- a/src/extension/param/description.cpp
+++ b/src/extension/param/description.cpp
@@ -13,10 +13,6 @@
# include "config.h"
#endif
-#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H
-#include <glibmm/threads.h>
-#endif
-
#include <gtkmm/box.h>
#include <gtkmm/label.h>
#include <glibmm/i18n.h>
diff --git a/src/extension/param/enum.cpp b/src/extension/param/enum.cpp
index 74b2a75ad..8bc0fbda7 100644
--- a/src/extension/param/enum.cpp
+++ b/src/extension/param/enum.cpp
@@ -18,10 +18,6 @@
# include "config.h"
#endif
-#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H
-#include <glibmm/threads.h>
-#endif
-
#include <gtkmm/box.h>
#include <gtkmm/comboboxtext.h>
#include <glibmm/i18n.h>
diff --git a/src/extension/param/float.cpp b/src/extension/param/float.cpp
index 464938f03..81508f6c0 100644
--- a/src/extension/param/float.cpp
+++ b/src/extension/param/float.cpp
@@ -10,10 +10,6 @@
# include "config.h"
#endif
-#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H
-#include <glibmm/threads.h>
-#endif
-
#include <gtkmm/adjustment.h>
#include <gtkmm/box.h>
#include <gtkmm/scale.h>
diff --git a/src/extension/param/int.cpp b/src/extension/param/int.cpp
index 819c75693..c286018fd 100644
--- a/src/extension/param/int.cpp
+++ b/src/extension/param/int.cpp
@@ -10,10 +10,6 @@
# include "config.h"
#endif
-#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H
-#include <glibmm/threads.h>
-#endif
-
#include <gtkmm/adjustment.h>
#include <gtkmm/box.h>
#include <gtkmm/scale.h>
diff --git a/src/extension/param/notebook.cpp b/src/extension/param/notebook.cpp
index 9ec31ca6b..20c8e8481 100644
--- a/src/extension/param/notebook.cpp
+++ b/src/extension/param/notebook.cpp
@@ -16,10 +16,6 @@
# include "config.h"
#endif
-#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H
-#include <glibmm/threads.h>
-#endif
-
#include <gtkmm/adjustment.h>
#include <gtkmm/box.h>
#include <gtkmm/spinbutton.h>
diff --git a/src/extension/param/radiobutton.cpp b/src/extension/param/radiobutton.cpp
index 740acf1d1..8181c6f51 100644
--- a/src/extension/param/radiobutton.cpp
+++ b/src/extension/param/radiobutton.cpp
@@ -18,10 +18,6 @@
# include "config.h"
#endif
-#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H
-#include <glibmm/threads.h>
-#endif
-
#include <gtkmm/box.h>
#include <gtkmm/comboboxtext.h>
#include <gtkmm/radiobutton.h>
diff --git a/src/extension/param/string.cpp b/src/extension/param/string.cpp
index d6e438db5..4e525ff73 100644
--- a/src/extension/param/string.cpp
+++ b/src/extension/param/string.cpp
@@ -10,10 +10,6 @@
# include "config.h"
#endif
-#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H
-#include <glibmm/threads.h>
-#endif
-
#include <gtkmm/adjustment.h>
#include <gtkmm/box.h>
#include <gtkmm/spinbutton.h>
diff --git a/src/extension/prefdialog.h b/src/extension/prefdialog.h
index 905d35744..4714c2c3f 100644
--- a/src/extension/prefdialog.h
+++ b/src/extension/prefdialog.h
@@ -10,19 +10,10 @@
#ifndef INKSCAPE_EXTENSION_DIALOG_H__
#define INKSCAPE_EXTENSION_DIALOG_H__
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H
-#include <glibmm/threads.h>
-#endif
-
#include <gtkmm/dialog.h>
#include <glibmm/value.h>
#include <glibmm/ustring.h>
-
namespace Gtk {
class CheckButton;
}