Michael Gilbert wrote, on 01/05/12 01:23: >> Are the segfaults depending on a special pdf-file? Do you have some examples >> for >> the problem? > > See the changelog entry for version 3.03-3. > > Best wishes, > Mike > >
Using a scenario which leads to a reproducable crash of xpdf 3.03 patched with fix-580495.patch, I was able to repair this patch. I mainly switched back to a fixed array "zoomMenuBtns". [By the way, in my case the error message was something like *** glibc detected *** x/xpdf-3.03/xpdf/xpdf: malloc(): smallbin double linked list corrupted: 0x0000000001a15050 *** ] Please find attached the changed version of fix-580495.patch. Best regards, Jörg-Volker.
description: add additional zoom features This merges 2 different feature patches into one working one. http://bugs.debian.org/424178 hight patch http://bugs.debian.org/578892 bug fix to hight patch http://bugs.debian.org/580495 high mag zoom author: Rogério Brito, Josh Triplett, Emmanuel Thomé, Jörg-Volker Peetz debian-bug: http://bugs.debian.org/580495 Index: xpdf/xpdf/XPDFViewer.cc =================================================================== --- xpdf.orig/xpdf/XPDFViewer.cc 2011-08-15 23:08:53.000000000 +0200 +++ xpdf/xpdf/XPDFViewer.cc 2012-01-05 11:52:19.006365920 +0100 @@ -15,6 +15,7 @@ #include <stdlib.h> #include <string.h> #include <ctype.h> +#include <assert.h> #include <X11/keysym.h> #include <X11/cursorfont.h> #ifdef HAVE_X11_XPM_H @@ -138,7 +139,11 @@ double zoom; }; -static ZoomMenuInfo zoomMenuInfo[nZoomMenuItems] = { +static ZoomMenuInfo zoomMenuInfo[] = { + { "1600%", 1600 }, + { "1200%", 1200 }, + { "800%", 800 }, + { "600%", 600 }, { "400%", 400 }, { "200%", 200 }, { "150%", 150 }, @@ -148,14 +153,16 @@ { "25%", 25 }, { "12.5%", 12.5 }, { "fit page", zoomPage }, - { "fit width", zoomWidth } + { "fit width", zoomWidth }, + { "fit height", zoomHeight } }; #define maxZoomIdx 0 -#define defZoomIdx 3 -#define minZoomIdx 7 -#define zoomPageIdx 8 -#define zoomWidthIdx 9 +#define defZoomIdx 7 +#define minZoomIdx nZoomMenuItems - 4 +#define zoomPageIdx nZoomMenuItems - 3 +#define zoomWidthIdx nZoomMenuItems - 2 +#define zoomHeightIdx nZoomMenuItems -1 //------------------------------------------------------------------------ @@ -230,6 +237,7 @@ { "toggleFullScreenMode", 0, gFalse, gFalse, &XPDFViewer::cmdToggleFullScreenMode }, { "toggleOutline", 0, gFalse, gFalse, &XPDFViewer::cmdToggleOutline }, { "windowMode", 0, gFalse, gFalse, &XPDFViewer::cmdWindowMode }, + { "zoomFitHeight", 0, gFalse, gFalse, &XPDFViewer::cmdZoomFitHeight }, { "zoomFitPage", 0, gFalse, gFalse, &XPDFViewer::cmdZoomFitPage }, { "zoomFitWidth", 0, gFalse, gFalse, &XPDFViewer::cmdZoomFitWidth }, { "zoomIn", 0, gFalse, gFalse, &XPDFViewer::cmdZoomIn }, @@ -249,6 +257,8 @@ int pg; double z; + assert(nZoomMenuItems == sizeof(zoomMenuInfo)/sizeof(struct ZoomMenuInfo)); + app = appA; win = NULL; core = NULL; @@ -1421,6 +1431,15 @@ } } +void XPDFViewer::cmdZoomFitHeight(GString *args[], int nArgs, + XEvent *event) { + if (core->getZoom() != zoomHeight) { + setZoomIdx(zoomHeightIdx); + displayPage(core->getPageNum(), zoomHeight, + core->getRotate(), gTrue, gFalse); + } +} + void XPDFViewer::cmdZoomIn(GString *args[], int nArgs, XEvent *event) { int z; @@ -1803,7 +1822,7 @@ menuPane = XmCreatePulldownMenu(toolBar, "zoomMenuPane", args, n); for (i = 0; i < nZoomMenuItems; ++i) { n = 0; - s = XmStringCreateLocalized(zoomMenuInfo[i].label); + s = XmStringCreateLocalized((char*)zoomMenuInfo[i].label); XtSetArg(args[n], XmNlabelString, s); ++n; XtSetArg(args[n], XmNuserData, (XtPointer)i); ++n; sprintf(buf, "zoom%d", i); Index: xpdf/xpdf/XPDFViewer.h =================================================================== --- xpdf.orig/xpdf/XPDFViewer.h.orig 2011-08-15 23:08:53.000000000 +0200 +++ xpdf/xpdf/XPDFViewer.h 2012-01-05 11:35:00.653055561 +0100 @@ -41,7 +41,7 @@ //------------------------------------------------------------------------ // NB: this must match the defn of zoomMenuBtnInfo in XPDFViewer.cc -#define nZoomMenuItems 10 +#define nZoomMenuItems 15 //------------------------------------------------------------------------ @@ -54,6 +54,8 @@ }; //------------------------------------------------------------------------ + +//------------------------------------------------------------------------ // XPDFViewer //------------------------------------------------------------------------ @@ -170,6 +172,7 @@ void cmdWindowMode(GString *args[], int nArgs, XEvent *event); void cmdZoomFitPage(GString *args[], int nArgs, XEvent *event); void cmdZoomFitWidth(GString *args[], int nArgs, XEvent *event); + void cmdZoomFitHeight(GString *args[], int nArgs, XEvent *event); void cmdZoomIn(GString *args[], int nArgs, XEvent *event); void cmdZoomOut(GString *args[], int nArgs, XEvent *event); void cmdZoomPercent(GString *args[], int nArgs, XEvent *event); Index: xpdf/doc/xpdf.1 =================================================================== --- xpdf.orig/doc/xpdf.1 2011-08-28 19:56:32.000000000 -0400 +++ xpdf/doc/xpdf.1 2011-08-28 20:20:24.000000000 -0400 @@ -100,7 +100,7 @@ Set the initial zoom factor. A number specifies a zoom percentage, where 100 means 72 dpi. You may also specify \'page', to fit the page to the window size, or \'width', to fit the page width to the window -width. +width, or \'height', to fit the page height to the window height .RB "[config file: " initialZoom "; or X resource: " xpdf.initialZoom ] .TP .B \-cont @@ -439,6 +439,9 @@ .B w Set the zoom factor to 'width' (fit page width to window). .TP +.B h +Set the zoom factor to 'height' (fit page height to window). +.TP .B alt-F Toggle full-screen mode. .TP @@ -591,6 +594,9 @@ .B zoomFitWidth Set the zoom factor to fit-width. .TP +.B zoomFitHeight +Set the zoom factor to fit-height. +.TP .B zoomIn Zoom in - go to the next higher zoom factor. .TP @@ -813,6 +819,7 @@ bind - any zoomOut bind z any zoomFitPage bind w any zoomFitWidth + bind h any zoomFitHeight bind alt-f any toggleFullScreenMode bind ctrl-l any redraw bind ctrl-w any closeWindow Index: xpdf/doc/xpdfrc.5 =================================================================== --- xpdf.orig/doc/xpdfrc.5 2011-08-28 19:54:15.000000000 -0400 +++ xpdf/doc/xpdfrc.5 2011-08-28 20:18:25.000000000 -0400 @@ -365,11 +365,11 @@ cross-hatching. This defaults to "no". .SH MISCELLANEOUS SETTINGS .TP -.BR initialZoom " \fIpercentage\fR | page | width" +.BR initialZoom " \fIpercentage\fR | page | width | height" Sets the initial zoom factor. A number specifies a zoom percentage, where 100 means 72 dpi. You may also specify \'page', to fit the page -to the window size, or \'width', to fit the page width to the window -width. +to the window size, \'width', to fit the page width to the window width, +or \'height', to fit the page height to the window height. .TP .BR continuousView " yes | no" If set to "yes", xpdf will start in continuous view mode, i.e., with Index: xpdf/xpdf/GlobalParams.cc =================================================================== --- xpdf.orig/xpdf/GlobalParams.cc 2011-08-28 20:11:40.000000000 -0400 +++ xpdf/xpdf/GlobalParams.cc 2011-08-28 20:18:25.000000000 -0400 @@ -922,6 +922,8 @@ xpdfKeyContextAny, "zoomFitPage")); keyBindings->append(new KeyBinding('w', xpdfKeyModNone, xpdfKeyContextAny, "zoomFitWidth")); + keyBindings->append(new KeyBinding('h', xpdfKeyModNone, + xpdfKeyContextAny, "zoomFitHeight")); keyBindings->append(new KeyBinding('f', xpdfKeyModAlt, xpdfKeyContextAny, "toggleFullScreenMode")); Index: xpdf/xpdf/PDFCore.cc =================================================================== --- xpdf.orig/xpdf/PDFCore.cc 2011-08-28 20:11:43.000000000 -0400 +++ xpdf/xpdf/PDFCore.cc 2011-08-28 20:18:25.000000000 -0400 @@ -462,6 +462,12 @@ dpiA = (hDPI < vDPI) ? hDPI : vDPI; } else if (zoomA == zoomWidth) { dpiA = (drawAreaWidth / uw) * 72; + } else if (zoomA == zoomHeight) { + if (continuousMode) { + dpiA = ((drawAreaHeight - continuousModePageSpacing) / uh) * 72; + } else { + dpiA = (drawAreaHeight / uh) * 72; + } } else { dpiA = 0.01 * zoomA * 72; } @@ -1216,6 +1222,24 @@ dpi1 = 72.0 * (double)drawAreaWidth / pageW; sx = 0; + } else if (zoomA == zoomHeight) { + if (continuousMode) { + pageH = (rotate == 90 || rotate == 270) ? maxUnscaledPageW + : maxUnscaledPageH; + dpi1 = 72.0 * (double)(drawAreaHeight - continuousModePageSpacing) / pageH; + } else { + rot = rotate + doc->getPageRotate(topPage); + if (rot >= 360) { + rot -= 360; + } else if (rot < 0) { + rot += 360; + } + pageH = (rot == 90 || rot == 270) ? doc->getPageCropWidth(topPage) + : doc->getPageCropHeight(topPage); + dpi1 = 72.0 * (double)drawAreaHeight / pageH; + } + sx = 0; + } else if (zoomA <= 0) { return; Index: xpdf/xpdf/PDFCore.h =================================================================== --- xpdf.orig/xpdf/PDFCore.h 2011-08-28 19:12:29.000000000 -0400 +++ xpdf/xpdf/PDFCore.h 2011-08-28 20:18:25.000000000 -0400 @@ -39,6 +39,7 @@ #define zoomPage -1 #define zoomWidth -2 +#define zoomHeight -3 #define defZoom 125 //------------------------------------------------------------------------ Index: xpdf/xpdf/XPDFCore.cc =================================================================== --- xpdf.orig/xpdf/XPDFCore.cc 2011-08-28 20:13:51.000000000 -0400 +++ xpdf/xpdf/XPDFCore.cc 2011-08-28 20:18:25.000000000 -0400 @@ -121,6 +121,8 @@ zoom = zoomPage; } else if (!initialZoom->cmp("width")) { zoom = zoomWidth; + } else if (!initialZoom->cmp("height")) { + zoom = zoomHeight; } else { zoom = atoi(initialZoom->getCString()); if (zoom <= 0) { @@ -249,7 +251,7 @@ width1 = doc->getPageCropWidth(pg); height1 = doc->getPageCropHeight(pg); } - if (zoom == zoomPage || zoom == zoomWidth) { + if (zoom == zoomPage || zoom == zoomWidth || zoom == zoomHeight) { width = (Dimension)(width1 * 0.01 * defZoom + 0.5); height = (Dimension)(height1 * 0.01 * defZoom + 0.5); } else { @@ -1050,7 +1052,7 @@ XtGetValues(core->drawArea, args, n); core->drawAreaWidth = (int)w; core->drawAreaHeight = (int)h; - if (core->zoom == zoomPage || core->zoom == zoomWidth) { + if (core->zoom == zoomPage || core->zoom == zoomWidth || core->zoom == zoomHeight) { sx = sy = -1; } else { sx = core->scrollX;