summaryrefslogtreecommitdiff
path: root/app-editors/nedit/files/nedit-5.6-fix-crash-with-noX.patch
blob: 92b0778e2ab2c09cb49b6173c740849ac8b9b229 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
diff -urN a/source/highlightData.c b/source/highlightData.c
--- a/source/highlightData.c	2018-03-13 08:42:40.930188154 +0100
+++ b/source/highlightData.c	2018-03-13 08:44:59.651196431 +0100
@@ -1280,7 +1280,7 @@
     XFontStruct *font;
     
     if (styleNo<0)
-        return GetDefaultFontStruct(window->fontList);
+	return GetDefaultFontStruct(TheDisplay, window->fontList);
     fontNum = HighlightStyles[styleNo]->font;
     if (fontNum == BOLD_FONT)
     	font = window->boldFontStruct;
@@ -1289,10 +1289,10 @@
     else if (fontNum == BOLD_ITALIC_FONT)
     	font = window->boldItalicFontStruct;
     else /* fontNum == PLAIN_FONT */
-    	font = GetDefaultFontStruct(window->fontList);
+	font = GetDefaultFontStruct(TheDisplay, window->fontList);
     
     /* If font isn't loaded, silently substitute primary font */
-    return font == NULL ? GetDefaultFontStruct(window->fontList) : font;
+    return font == NULL ? GetDefaultFontStruct(TheDisplay, window->fontList) : font;
 }
 
 int FontOfNamedStyleIsBold(char *styleName)
diff -urN a/source/text.c b/source/text.c
--- a/source/text.c	2018-03-13 08:42:40.931188154 +0100
+++ b/source/text.c	2018-03-13 08:46:37.785202286 +0100
@@ -778,9 +778,13 @@
     textBuffer *buf;
     Pixel white, black;
     int textLeft;
-    int charWidth = fs->max_bounds.width;
-    int marginWidth = new->text.marginWidth;
-    int lineNumCols = new->text.lineNumCols;
+    int charWidth;
+    int marginWidth;
+    int lineNumCols;
+
+    charWidth = fs->max_bounds.width;
+    marginWidth = new->text.marginWidth;
+    lineNumCols = new->text.lineNumCols;
     
     /* Set the initial window size based on the rows and columns resources */
     if (request->core.width == 0)
diff -urN a/source/window.c b/source/window.c
--- a/source/window.c	2018-03-13 08:42:40.937188155 +0100
+++ b/source/window.c	2018-03-13 08:48:07.727207652 +0100
@@ -1839,7 +1839,7 @@
 
     /* Change the primary font in all the widgets */
     if (primaryChanged) {
-        font = GetDefaultFontStruct(window->fontList);
+	font = GetDefaultFontStruct(TheDisplay, window->fontList);
         XtVaSetValues(window->textArea, textNfont, font, NULL);
         for (i=0; i<window->nPanes; i++)
             XtVaSetValues(window->textPanes[i], textNfont, font, NULL);
@@ -1861,7 +1861,7 @@
        size appropriate for the new font, but only do so if there's only
        _one_ document in the window, in order to avoid growing-window bug */
     if (NDocuments(window) == 1) {
-	fontWidth = GetDefaultFontStruct(window->fontList)->max_bounds.width;
+	fontWidth = GetDefaultFontStruct(TheDisplay, window->fontList)->max_bounds.width;
 	fontHeight = textD->ascent + textD->descent;
 	newWindowWidth = (oldTextWidth*fontWidth) / oldFontWidth + borderWidth;
 	newWindowHeight = (oldTextHeight*fontHeight) / oldFontHeight + 
@@ -2244,7 +2244,7 @@
             textNrows, rows, textNcolumns, cols,
             textNlineNumCols, lineNumCols,
             textNemulateTabs, emTabDist,
-            textNfont, GetDefaultFontStruct(window->fontList),
+	    textNfont, GetDefaultFontStruct(TheDisplay, window->fontList),
             textNhScrollBar, hScrollBar, textNvScrollBar, vScrollBar,
             textNreadOnly, IS_ANY_LOCKED(window->lockReasons),
             textNwordDelimiters, delimiters,

--- a/util/misc.c	2018-03-13 08:50:54.892217626 +0100
+++ b/util/misc.c	2018-03-13 08:56:50.346238834 +0100
@@ -1018,7 +1018,7 @@
 ** a Motif font list.  Since Motif stores this, it saves us from storing
 ** it or querying it from the X server.
 */
-XFontStruct *GetDefaultFontStruct(XmFontList font)
+XFontStruct *GetDefaultFontStruct(Display *d, XmFontList font)
 {
     XFontStruct *fs;
     XmFontContext context;
@@ -1028,6 +1028,17 @@
     XmFontListGetNextFont(context, &charset, &fs);
     XmFontListFreeFontContext(context);
     XtFree(charset);
+
+    /* FontList might be a render table with no only XFT fonts */ 
+    if (fs == NULL) {
+	fs = XLoadQueryFont(d, "fixed");
+    }
+
+    if (fs == NULL) {
+	fprintf(stderr, "Unabled to load any fallback fonts.\n");
+	exit(EXIT_FAILURE);
+    }
+
     return fs;
 }
    
diff -urN a/util/misc.h b/util/misc.h
--- a/util/misc.h	2018-03-13 08:50:54.890217626 +0100
+++ b/util/misc.h	2018-03-13 08:55:52.790235400 +0100
@@ -65,7 +65,7 @@
 void AccelLockBugPatch(Widget topWidget, Widget topMenuContainer);
 void UpdateAccelLockPatch(Widget topWidget, Widget newButton);
 char *GetXmStringText(XmString fromString);
-XFontStruct *GetDefaultFontStruct(XmFontList font);
+XFontStruct *GetDefaultFontStruct(Display *d, XmFontList font);
 XmString* StringTable(int count, ...);
 void FreeStringTable(XmString *table);
 void SimulateButtonPress(Widget widget);