How to modify a SVG attribute using XSLT - xslt

How can I modify a SVG file by using XSLT?
I like to modify the following SVG (cutout) file:
<svg width="834px" height="707.5px" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" overflow="visible">
<defs>
<symbol id="E003" viewBox="0 0 1000 1000" overflow="inherit">
<path transform="scale(1,-1)" d="M0 -0c49 0 97.5 -2.26367 135.5 4.73633c206 95 258.5 264.264 263.5 271.264c0 1 -14 7 -15 6c-88 -154 -251 -167 -321 -170c-1 0 -63 -1 -63 -1v-111z" />
</symbol>
<symbol id="E004" viewBox="0 0 1000 1000" overflow="inherit">
<path transform="scale(1,-1)" d="M0 0c49 0 97.5 2.26367 135.5 -4.73633c206 -95 258.5 -264.264 263.5 -271.264c0 -1 -14 -7 -15 -6c-88 154 -251 167 -321 170c-1 0 -63 1 -63 1v111z" />
</symbol>
<symbol id="E050" viewBox="0 0 1000 1000" overflow="inherit">
<path transform="scale(1,-1)" d="M441 -245c-23 -4 -48 -6 -76 -6c-59 0 -102 7 -130 20c-88 42 -150 93 -187 154c-26 44 -43 103 -48 176c-4 60 11 123 44 189c29 57 65 106 110 148s96 85 153 127c-3 16 -8 46 -13 92c-4 43 -5 73 -5 89c0 117 16 172 69 257c34 54 64 82 89 82c21 0 43 -30 69 -92 s39 -115 41 -159c2 -120 -19 -173 -67 -256c-13 -20 -63 -90 -98 -118c-13 -9 -25 -19 -37 -29l31 -181c8 1 18 2 28 2c58 0 102 -12 133 -35c59 -43 92 -104 98 -184c11 -135 -80 -229 -180 -270c8 -57 17 -110 25 -162c5 -31 6 -58 6 -80c0 -30 -5 -53 -14 -70 c-35 -64 -88 -99 -158 -103c-42 -3 -83 6 -124 26c-50 24 -77 59 -80 105c-2 34 5 63 20 87c18 28 45 42 79 44c51 4 99 -40 103 -87c4 -56 -30 -94 -105 -115c17 -24 51 -36 102 -36c62 0 116 43 140 85c9 16 13 41 13 74c0 20 -1 42 -5 67c-8 53 -18 106 -26 159zM461 939 c-95 0 -135 -175 -135 -286c0 -24 2 -48 5 -71c50 39 92 82 127 128c43 57 63 106 60 148c-4 54 -23 82 -57 81zM406 119l54 -326c80 27 116 88 109 184c-7 99 -62 146 -163 142zM382 117c-74 -2 -132 -50 -128 -127c2 -46 43 -99 75 -115c-3 -2 -7 -5 -10 -10 c-70 33 -116 88 -123 172c-5 73 42 135 88 170c23 17 49 29 78 36l-29 170c-21 -13 -52 -37 -92 -73c-50 -44 -86 -84 -109 -119c-49 -75 -71 -140 -67 -195c5 -68 35 -127 93 -176s125 -73 203 -73c25 0 50 3 75 9c-19 111 -36 221 -54 331z" />
</symbol>
<symbol id="E260" viewBox="0 0 1000 1000" overflow="inherit">
<path transform="scale(1,-1)" d="M20 110c32 16 54 27 93 27c26 0 35 -3 54 -13c13 -7 24 -20 27 -38l4 -25c0 -28 -16 -57 -45 -89c-23 -25 -39 -44 -65 -68l-88 -79v644h20v-359zM90 106c-32 0 -48 -10 -70 -29v-194c31 31 54 59 71 84c21 32 32 59 32 84c0 9 1 16 1 20c0 14 -3 21 -11 30l-8 3z" />
</symbol>
<symbol id="E0A4" viewBox="0 0 1000 1000" overflow="inherit">
<path transform="scale(1,-1)" d="M0 -39c0 68 73 172 200 172c66 0 114 -37 114 -95c0 -84 -106 -171 -218 -171c-64 0 -96 30 -96 94z" />
</symbol>
<symbol id="E262" viewBox="0 0 1000 1000" overflow="inherit">
<path transform="scale(1,-1)" d="M136 186v169h17v-164l44 14v-91l-44 -14v-165l44 12v-91l-44 -13v-155h-17v150l-76 -22v-155h-17v149l-43 -13v90l43 14v167l-43 -14v92l43 13v169h17v-163zM60 73v-167l76 22v168z" />
</symbol>
</defs>
<style type="text/css">g.page-margin{font-family:Times;} g.tempo{font-weight:bold;} g.dir, g.dynam, g.mNum{font-style:italic;} g.label{font-weight:normal;}</style>
<svg class="definition-scale" viewBox="0 0 16680 14150">
<g class="page-margin" transform="translate(500, 500)">
<g class="system" id="system-0000000155158177">
<path d="M2099 720 L2099 5782" stroke="#000000" stroke-width="27" />
<use xlink:href="#E003" x="1919" y="720" height="720px" width="720px" />
<use xlink:href="#E004" x="1919" y="5782" height="720px" width="720px" />
<rect x="1919" y="702" height="5098" width="90" />
<use xlink:href="#E003" x="1797" y="720" height="720px" width="720px" />
<use xlink:href="#E004" x="1797" y="2880" height="720px" width="720px" />
<rect x="1797" y="702" height="2196" width="90" />
<g class="labelAbbr" id="labelAbbr-0000001982553912">
<text x="1546" y="1170" text-anchor="end" font-size="0px">
<tspan class="text" id="text-0000000427332132">
<tspan font-size="405px" class="text">C Tpt. 1</tspan>
</tspan>
</text>
</g>
<g class="labelAbbr" id="labelAbbr-0000001715657114">
<text x="1546" y="2610" text-anchor="end" font-size="0px">
<tspan class="text" id="text-0000000786186729">
<tspan font-size="405px" class="text">C Tpt. 2</tspan>
</tspan>
</text>
</g>
<g class="labelAbbr" id="labelAbbr-0000000404188205">
<text x="1816" y="4072" text-anchor="end" font-size="0px">
<tspan class="text" id="text-0000000700385974">
<tspan font-size="405px" class="text">Tbn.</tspan>
</tspan>
</text>
</g>
<g class="labelAbbr" id="labelAbbr-0000001796530924">
<text x="1816" y="5512" text-anchor="end" font-size="0px">
<tspan class="text" id="text-0000000675162848">
<tspan font-size="405px" class="text">B. Tbn.</tspan>
</tspan>
</text>
</g>
<g class="sb" id="sb-0000001000252933" />
<g class="measure" id="d1e4299">
<g class="mNum autogenerated" id="mnum-0000001212157683">
<text x="2086" y="450" text-anchor="middle" font-size="0px">
<tspan class="text" id="text-0000001704302739">
<tspan font-size="324px" class="text">22</tspan>
</tspan>
</text>
</g>
<g class="staff" id="staff-0000001329456927">
<path d="M2086 720 L7292 720" stroke="#000000" stroke-width="13" />
<path d="M2086 900 L7292 900" stroke="#000000" stroke-width="13" />
<path d="M2086 1080 L7292 1080" stroke="#000000" stroke-width="13" />
<path d="M2086 1260 L7292 1260" stroke="#000000" stroke-width="13" />
<path d="M2086 1440 L7292 1440" stroke="#000000" stroke-width="13" />
<g class="clef" id="clef-0000001591308631">
<use xlink:href="#E050" x="2176" y="1260" height="720px" width="720px" />
</g>
<g class="keySig" id="keysig-0000000362821479">
<use xlink:href="#E260" x="2857" y="1080" height="720px" width="720px" />
</g>
<g class="layer" id="layer-0000001762708701">
<g class="note" id="d1e4305">
<use xlink:href="#E0A4" x="3559" y="1350" height="720px" width="720px" />
<g class="stem">
<rect x="3767" y="720" height="608" width="18" />
</g>
<g class="accid" id="accid-0000001439359008">
<use xlink:href="#E262" x="3364" y="1350" height="720px" width="720px" />
</g>
</g>
<g class="note" id="d1e4323">
<use xlink:href="#E0A4" x="4423" y="1350" height="720px" width="720px" />
<g class="stem">
<rect x="4631" y="720" height="608" width="18" />
</g>
<g class="accid" id="accid-0000000550318292" />
</g>
<g class="note" id="d1e4339">
<use xlink:href="#E0A4" x="5551" y="1260" height="720px" width="720px" />
<g class="stem">
<rect x="5759" y="630" height="608" width="18" />
</g>
</g>
<g class="note" id="d1e4353">
<use xlink:href="#E0A4" x="6415" y="900" height="720px" width="720px" />
<g class="stem">
<rect x="6415" y="922" height="608" width="18" />
</g>
</g>
</g>
</g>
</g>
</g>
</g>
</svg>
</svg>
I want to change the color for the symbol id="E050". To achieve this I tried to add the attribute fill="#ff0000" to the symbol definition.
This is the current version of my XSL file:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg">
<xsl:template match="node() | #*">
<xsl:copy>
<xsl:apply-templates select="node() | #*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="//symbol[#id='E050']">
<xsl:copy>
<xsl:apply-templates select="#*"/>
<xsl:attribute name="fill">#ff0000</xsl:attribute>
<xsl:apply-templates select="node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
How can I modify the XSL file that the color for the symbol id="E050 is changed but the rest is not modified?
To test the modification I'm using the online tool https://www.w3schools.com/xml/tryxslt.asp?xmlfile=cdcatalog&xsltfile=cdcatalog_ex1.

Change this line...
<xsl:template match="//symbol[#id='E050']">
To this line....
<xsl:template match="svg:symbol[#id='E050']">
(Note the // prefix is not necessary in a template match)
Although you have a default namespace declaration in your XSLT (xmlns="http://www.w3.org/2000/svg") this only applies to unprefixed elements in your XSLT (which also happens to be an XML document), not Xpath expressions in attributes. This doing a match on symbol[#id='E050'] is trying to match a symbol element in no namespace.
Alternatively, if you could use XSLT 2.0, you could add this line to the xsl:stylesheet element, as this would then mean unprefixed element names in xpath expressions would be given a namespace
xpath-default-namespace="http://www.w3.org/2000/svg"

Related

XSLT 2.0 sort using letters and numbers

I have a sequence of strings that look like this:
B5 C10 C8 D11 D13 D3 D7 D9 E12 E8
I did the <xsl:perform-sort and <xsl:sort, based on the default data-type="text" and it's working correctly. But I would like to further sort so that after the letter the values are sorted numerically:
B5 C8 C10 D3 D7 D9 D11 D13 E8 E12
Any suggestions on how to do that? Thanks!
Edited to add my code:
<xsl:variable name="pns1" as="xs:string*">
<xsl:perform-sort select="distinct-values($combo1/*:pin/*:pkg[$pos]/*:pn/#n)">
<xsl:sort select="."/>
</xsl:perform-sort>
</xsl:variable>
<xsl:variable name="pns2" as="xs:string*">
<xsl:perform-sort select="$pns1">
<xsl:sort select="." data-type="number"/>
</xsl:perform-sort>
</xsl:variable>
<xsl:message select="$pns2"/>
Saxon allows you a parameter alphanumeric="yes" on a collation URI, see https://www.saxonica.com/html/documentation11/localization/unicode-collation-algorithm/ so e.g.
'B5 C10 C8 D11 D13 D3 D7 D9 E12 E8'
=> tokenize('\s+')
=> sort('http://www.w3.org/2013/collation/UCA?alphanumeric=yes')
gives
B5 C8 C10 D3 D7 D9 D11 D13 E8 E12
.
Online fiddle with Saxon XQuery (but XPath/XSLT support it the same): https://xqueryfiddle.liberty-development.net/jyH9Xvk.
Using numeric=yes;fallback=yes might even give better compatibility between the various Saxon editions (HE, PE, EE) and platforms (Java, .NET):
'B5 C10 C8 D11 D13 D3 D7 D9 E12 E8'
=> tokenize('\s+')
=> sort('http://www.w3.org/2013/collation/UCA?numeric=yes;fallback=yes')
or even SaxonJS.
Consider the following example:
XSLT 2.0
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:variable name="strings" select="('D13', 'B5', 'C10', 'E12', 'C8', 'D11', 'D3', 'E8', 'D7', 'D9')" />
<xsl:template match="/">
<result>
<xsl:perform-sort select="$strings">
<xsl:sort select="substring(., 1, 1)"/>
<xsl:sort select="substring(., 2)" data-type="number"/>
</xsl:perform-sort>
</result>
</xsl:template>
</xsl:stylesheet>
Result
<?xml version="1.0" encoding="UTF-8"?>
<result>B5 C8 C10 D3 D7 D9 D11 D13 E8 E12</result>

AVX512 Vectorizing Modulo Gives Negative Result For Very Large Inputs

I am currently trying to vectorize a modulo calculation using AVX512.
Because there is no AVX modulo operation (except SVML) or an integer division, I am using the following formula d % p = d - int(float(d)/float(p))*p.
However, for very large inputs, I get negative results.
#include <bits/stdc++.h>
#include <immintrin.h>
int main() {
const auto SIZE = 1024;
int64_t input[SIZE];
int64_t output[SIZE] = {};
const auto p = 1'536; // 1.5 * 1024
std::iota(input, input + SIZE, 15596705878733779060ULL);
__m512i _divider_512 = _mm512_set1_epi64(p);
for (size_t idx = 0; idx < SIZE; idx += 8) {
__m512i _inputs = _mm512_loadu_si512(&input[idx]);
__m512i _e = _mm512_cvt_roundpd_epi64(_mm512_div_pd(_mm512_cvtepi64_pd(_inputs), _mm512_cvtepi64_pd(_divider_512)), _MM_FROUND_TO_NEG_INF | _MM_FROUND_NO_EXC);
__m512i _mult = _mm512_mullo_epi64(_e, _divider_512);
__m512i _modulo_result = _mm512_sub_epi64(_inputs, _mult);
_mm512_storeu_si512(&output[idx], _modulo_result);
}
for (auto i = 0; i< SIZE; ++i) {
std::cout << output[i] << std::endl;
}
}
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
-255
-254
-253
-252
-251
-250
-249
-248
-247
-246
-245
-244
-243
-242
-241
-240
-239
-238
-237
-236
-235
-234
-233
-232
-231
-230
-229
-228
-227
-226
-225
-224
-223
-222
-221
-220
-219
-218
-217
-216
-215
-214
-213
-212
-211
-210
-209
-208
-207
-206
-205
-204
-203
-202
-201
-200
-199
-198
-197
-196
-195
-194
-193
-192
-191
-190
-189
-188
-187
-186
-185
-184
-183
-182
-181
-180
-179
-178
-177
-176
-175
-174
-173
-172
-171
-170
-169
-168
-167
-166
-165
-164
-163
-162
-161
-160
-159
-158
-157
-156
-155
-154
-153
-152
-151
-150
-149
-148
-147
-146
-145
-144
-143
-142
-141
-140
-139
-138
-137
-136
-135
-134
-133
-132
-131
-130
-129
-128
-127
-126
-125
-124
-123
-122
-121
-120
-119
-118
-117
-116
-115
-114
-113
-112
-111
-110
-109
-108
-107
-106
-105
-104
-103
-102
-101
-100
-99
-98
-97
-96
-95
-94
-93
-92
-91
-90
-89
-88
-87
-86
-85
-84
-83
-82
-81
-80
-79
-78
-77
-76
-75
-74
-73
-72
-71
-70
-69
-68
-67
-66
-65
-64
-63
-62
-61
-60
-59
-58
-57
-56
-55
-54
-53
-52
-51
-50
-49
-48
-47
-46
-45
-44
-43
-42
-41
-40
-39
-38
-37
-36
-35
-34
-33
-32
-31
-30
-29
-28
-27
-26
-25
-24
-23
-22
-21
-20
-19
-18
-17
-16
-15
-14
-13
-12
-11
-10
-9
-8
-7
-6
-5
-4
-3
-2
-1
0
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
Is this a rounding error between ints and doubles? Or am I missing something else?
And how could I workaround it?

Extracting Minimum value after subsetting in PROC SQL

I have a sample dataset named Flights.I want to Extract from it the Origin
Airport name which has least number of departure delays.
Sample Flights data:-
Date (Sched_dep_time) (dep_time)(flight)(origin) (Dep_delay_min)
01-01-2013 5:15 5:17 1545 EWR -2
01-01-2013 5:29 5:33 1714 LGA -4
01-01-2013 5:40 5:42 1141 JFK -2
01-01-2013 21:10 21:04 725 JFK 6
01-01-2013 20:30 21:04 461 LGA -74
01-01-2013 21:06 21:05 1696 EWR 1
01-01-2013 20:55 21:10 507 EWR -55
01-01-2013 20:25 21:14 5708 LGA -89
01-01-2013 21:10 21:15 79 JFK -5
01-01-2013 21:24 21:16 301 LGA 8
01-01-2013 6:00 5:58 49 JFK 42
01-01-2013 6:00 5:58 71 JFK 42
01-01-2013 6:00 5:58 194 JFK 42
Code i Tried: -
Proc sql;
Create table least_delay as
Select origin,min(number_of_delays)as min_delay from
(Select Origin,Count(Departure_delay_minutes) as Number_of_delays from
Flight
Where (Departure_delay_minutes>0))
Group by Origin
;
Quit;
The output i get is following: -
Origin min_delay
1 NLI 1135504
2 JFK 1135504
3 LGA 1135504
It shows same result for all the origin!
Can anybody help me on this?
The specific problem in your code is that you need to add a group by Origin clause in the sub query. However, all this would do is return the number of delays for each Origin, not the Origin(s) with the least delay. A small change to the code, adding a having clause, fixes this.
data flight;
input Date :ddmmyy10. (Sched_dep_time dep_time) (:time.) flight origin $ Dep_delay_min;
format date date9. Sched_dep_time dep_time time. ;
datalines;
01-01-2013 5:15 5:17 1545 EWR -2
01-01-2013 5:29 5:33 1714 LGA -4
01-01-2013 5:40 5:42 1141 JFK -2
01-01-2013 21:10 21:04 725 JFK 6
01-01-2013 20:30 21:04 461 LGA -74
01-01-2013 21:06 21:05 1696 EWR 1
01-01-2013 20:55 21:10 507 EWR -55
01-01-2013 20:25 21:14 5708 LGA -89
01-01-2013 21:10 21:15 79 JFK -5
01-01-2013 21:24 21:16 301 LGA 8
01-01-2013 6:00 5:58 49 JFK 42
01-01-2013 6:00 5:58 71 JFK 42
01-01-2013 6:00 5:58 194 JFK 42
;
run;
proc sql;
create table least_delay
as select *
from (
select
origin,
count(0) as num_delays
from
flight
where
dep_delay_min>0
group by
origin
)
having num_delays = min(num_delays);
quit;

I don't understand the behavior of char in this example

So I have the following code :
int main()
{
int b=0;
for(char c=0;c<256;c++)
b++;
cout<<b;
return 0;
}
Why does it run indefinitely? (I tried c<255 - because I thought of char like a circle:once it reaches 360 degrees, it goes back from 0 and c<255 should break this loop - it turned out it still ran indefinitely)
Why does it run indefinitely?
Irrespective of whether char is signed type or unsigned type, it will not reach the value of 256 if char is represented by 8 bits, which is the most common representation. It will always be less than 256.
Why don't you run the code and print value to understand how char c in your code is getting incremented?
int b=0;
for(char c=0;c<256;c++)
{
cout<<(int)c<<" ";
b++;
if(b == 256)break;
}
This code snippet outputs the following.
0 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 119 120 121 122 123 124 125 126 127
-128 -127 -126 -125 -124 -123 -122 -121 -120 -119 -118 -117 -116 -115 -114 -113
-112 -111 -110 -109 -108 -107 -106 -105 -104 -103 -102 -101 -100 -99 -98 -97 -96
-95 -94 -93 -92 -91 -90 -89 -88 -87 -86 -85 -84 -83 -82 -81 -80 -79 -78 -77 -76
-75 -74 -73 -72 -71 -70 -69 -68 -67 -66 -65 -64 -63 -62 -61 -60 -59 -58 -57 -56
-55 -54 -53 -52 -51 -50 -49 -48 -47 -46 -45 -44 -43 -42 -41 -40 -39 -38 -37 -36
-35 -34 -33 -32 -31 -30 -29 -28 -27 -26 -25 -24 -23 -22 -21 -20 -19 -18 -17 -16
-15 -14 -13 -12 -11 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1
So, char never gets to 256. It gets to 127, and then when you try to increment it again, it wraps to -128.
Remember, typically char is represented by 8 bits and for signed char, the range is -128 to 127 and for unsigned char, the range is 0 to 255.
That's why, the condition c < 256 always evaluates to true and your code runs indefinitely.

QWebView App crashes when loading (with logs) and painting

0 WTFCrash assertions.cpp 345 0x10f50517
1 WTF::OwnPtr::operator-> ownptr.h 72 0xffbc8cd
2 WebCore::BitmapTextureImageBuffer::updateContents texturemapperimagebuffer.cpp 62 0x109cb865
3 WebCore::TextureMapperTile::updateContents texturemappertile.cpp 70 0x109cfdb5
4 WebCore::TextureMapperTiledBackingStore::updateContents texturemappertiledbackingstore.cpp 147 0x109c1831
5 WebCore::GraphicsLayerTextureMapper::updateBackingStoreIfNeeded graphicslayertexturemapper.cpp 624 0x103b852e
6 WebCore::GraphicsLayerTextureMapper::flushCompositingStateForThisLayerOnly graphicslayertexturemapper.cpp 444 0x103b79b4
7 WebCore::GraphicsLayerTextureMapper::flushCompositingState graphicslayertexturemapper.cpp 591 0x103b78c7
8 WebCore::GraphicsLayerTextureMapper::flushCompositingState graphicslayertexturemapper.cpp 596 0x103b796f
9 WebCore::GraphicsLayerTextureMapper::flushCompositingState graphicslayertexturemapper.cpp 596 0x103b796f
10 WebCore::GraphicsLayerTextureMapper::flushCompositingState graphicslayertexturemapper.cpp 596 0x103b796f
11 WebCore::GraphicsLayerTextureMapper::flushCompositingState graphicslayertexturemapper.cpp 596 0x103b796f
12 WebCore::GraphicsLayerTextureMapper::flushCompositingState graphicslayertexturemapper.cpp 596 0x103b796f
13 WebCore::RenderLayerCompositor::flushPendingLayerChanges renderlayercompositor.cpp 399 0x1010ef84
14 WebCore::FrameView::flushCompositingStateForThisFrame frameview.cpp 937 0xffda850
15 WebCore::FrameView::paintContents frameview.cpp 3613 0xffdd1a0
16 QWebFrameAdapter::renderRelativeCoords qwebframeadapter.cpp 539 0xfb0787c
17 QWebFrame::render qwebframe.cpp 644 0x60e96a96
18 QWebFrame::render qwebframe.cpp 655 0x60e96a54
19 QWebView::paintEvent qwebview.cpp 833 0x60ea34e8
20 QWidget::event qwidget.cpp 8114 0x778e9b5c
21 QWebView::event qwebview.cpp 732 0x60ea30dc
22 QApplicationPrivate::notify_helper qapplication.cpp 3500 0x778a1dde
23 QApplication::notify qapplication.cpp 3465 0x7789fdbe
24 QCoreApplication::notifyInternal qcoreapplication.cpp 935 0x66412d04
25 QCoreApplication::sendSpontaneousEvent qcoreapplication.h 240 0x66528938
26 QWidgetPrivate::drawWidget qwidget.cpp 5151 0x778ef4f1
27 QWidgetBackingStore::doSync qwidgetbackingstore.cpp 1180 0x778b2a74
28 QWidgetBackingStore::sync qwidgetbackingstore.cpp 1027 0x778b0f40
29 QWidgetPrivate::syncBackingStore qwidget.cpp 1693 0x778f13e1
30 QWidget::event qwidget.cpp 8252 0x778e9ee2
31 QWebView::event qwebview.cpp 732 0x60ea30dc
32 QApplicationPrivate::notify_helper qapplication.cpp 3500 0x778a1dde
33 QApplication::notify qapplication.cpp 3465 0x7789fdbe
34 QCoreApplication::notifyInternal qcoreapplication.cpp 935 0x66412d04
35 QCoreApplication::sendEvent qcoreapplication.h 237 0x6641c0d9
36 QCoreApplicationPrivate::sendPostedEvents qcoreapplication.cpp 1539 0x66413ce6
37 QCoreApplication::sendPostedEvents qcoreapplication.cpp 1397 0x664117c2
38 QWindowsGuiEventDispatcher::sendPostedEvents qwindowsguieventdispatcher.cpp 88 0x5223bf1
39 qt_internal_proc qeventdispatcher_win.cpp 423 0x664aa392
40 _InternalCallWinProc USER32 0x77467834
41 UserCallWinProcCheckWow USER32 0x77467a9a
42 DispatchMessageWorker USER32 0x7746988e
43 DispatchMessageW USER32 0x774698f1
44 QEventDispatcherWin32::processEvents qeventdispatcher_win.cpp 757 0x664aac85
45 QWindowsGuiEventDispatcher::processEvents qwindowsguieventdispatcher.cpp 80 0x5223b1c
46 QEventLoop::processEvents qeventloop.cpp 137 0x6640eb8c
47 QEventLoop::exec qeventloop.cpp 212 0x6640ed82
48 MainWindow::waitForLoad mainwindow.cpp 345 0xe10fd2
49 MainWindow::thread mainwindow.cpp 460 0xe0729b
50 MainWindow::on_GoButton_clicked mainwindow.cpp 99 0xe04b32
51 MainWindow::qt_static_metacall moc_mainwindow.cpp 72 0xe2f5a8
52 MainWindow::qt_metacall moc_mainwindow.cpp 100 0xe2f53b
53 QMetaObject::metacall qmetaobject.cpp 309 0x6641ede0
54 QMetaObject::activate qobject.cpp 3695 0x6645da56
55 QMetaObject::activate qobject.cpp 3546 0x6645d411
56 QAbstractButton::clicked moc_qabstractbutton.cpp 294 0x77d4809b
57 QAbstractButtonPrivate::emitClicked qabstractbutton.cpp 544 0x779f6657
58 QAbstractButtonPrivate::click qabstractbutton.cpp 536 0x779f5bdb
59 QAbstractButton::mouseReleaseEvent qabstractbutton.cpp 1141 0x779f5042
60 QWidget::event qwidget.cpp 7962 0x778e957c
61 QAbstractButton::event qabstractbutton.cpp 1098 0x779f4ba1
62 QPushButton::event qpushbutton.cpp 682 0x77ab6f1b
63 QApplicationPrivate::notify_helper qapplication.cpp 3500 0x778a1dde
64 QApplication::notify qapplication.cpp 3067 0x7789e5ee
65 QCoreApplication::notifyInternal qcoreapplication.cpp 935 0x66412d04
66 QCoreApplication::sendSpontaneousEvent qcoreapplication.h 240 0x66528938
67 QApplicationPrivate::sendMouseEvent qapplication.cpp 2540 0x778a3123
68 QWidgetWindow::handleMouseEvent qwidgetwindow.cpp 505 0x779249f1
69 QWidgetWindow::event qwidgetwindow.cpp 180 0x77923c0e
70 QApplicationPrivate::notify_helper qapplication.cpp 3500 0x778a1dde
71 QApplication::notify qapplication.cpp 2953 0x7789dfb7
72 QCoreApplication::notifyInternal qcoreapplication.cpp 935 0x66412d04
73 QCoreApplication::sendSpontaneousEvent qcoreapplication.h 240 0x66528938
74 QGuiApplicationPrivate::processMouseEvent qguiapplication.cpp 1701 0x10c82af
75 QGuiApplicationPrivate::processWindowSystemEvent qguiapplication.cpp 1502 0x10ca1d9
76 QWindowSystemInterface::sendWindowSystemEvents qwindowsysteminterface.cpp 579 0x10acad1
77 QWindowsGuiEventDispatcher::sendPostedEvents qwindowsguieventdispatcher.cpp 89 0x5223c01
78 qt_internal_proc qeventdispatcher_win.cpp 423 0x664aa392
79 _InternalCallWinProc USER32 0x77467834
80 UserCallWinProcCheckWow USER32 0x77467a9a
81 DispatchMessageWorker USER32 0x7746988e
82 DispatchMessageW USER32 0x774698f1
83 QEventDispatcherWin32::processEvents qeventdispatcher_win.cpp 757 0x664aac85
84 QWindowsGuiEventDispatcher::processEvents qwindowsguieventdispatcher.cpp 80 0x5223b1c
85 QEventLoop::processEvents qeventloop.cpp 137 0x6640eb8c
86 QEventLoop::exec qeventloop.cpp 212 0x6640ed82
87 QCoreApplication::exec qcoreapplication.cpp 1188 0x66411312
88 QGuiApplication::exec qguiapplication.cpp 1437 0x10c6e78
89 QApplication::exec qapplication.cpp 2746 0x7789dab9
90 main main.cpp 10 0xe02c18 91 WinMain qtmain_win.cpp 131 0xe3145a
92 __tmainCRTStartup crtexe.c 528 0xe30872
93 WinMainCRTStartup crtexe.c 377 0xe3063d
94 BaseThreadInitThunk KERNEL32 0x772f919f
95 __RtlUserThreadStart ntdll 0x7771a8cb
96 _RtlUserThreadStart ntdll 0x7771a8a1
It outputs
QPainter::begin: Paint device returned engine == 0, type: 2 ASSERTION
FAILED: m_ptr
c:\work\build\qt5_workdir\w\s\qtwebkit\Source\WTF\wtf/OwnPtr.h(72) :
WTF::OwnPtr::operator ->
In function
bool MainWindow::waitForLoad(QWebView& view)
{
QEventLoop loopLoad;
QTimer timer;
QObject::connect(&view, SIGNAL(loadFinished(bool)), &loopLoad, SLOT(quit()));
QObject::connect(&view, SIGNAL(loadFinished(bool)), &timer, SLOT(stop()));
QObject::connect(&timer, SIGNAL(timeout()), &loopLoad, SLOT(quit()));
timer.start(timeout);
loopLoad.exec();
if(timer.isActive())
{
timer.stop();
view.stop();
return false;
}
return true;
}
On the line "loopLoad.exec();"
Please help me. What's wrong with my code? Or how to fix that? I ready to disable any user-controls, css, images and ect. Advise me how to make it work
I know the answer! To fix this problem, enable autoload images!