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
|
From: leonb <leonb>
Date: Wed, 24 Nov 2010 01:57:04 +0000 (+0000)
Subject: Fixed occasional segfault when flipping pages very quickly.
X-Git-Tag: debian/4.6-2~27
X-Git-Url: http://djvu.git.sourceforge.net/git/gitweb.cgi?p=djvu%2Fdjview.git;a=commitdiff_plain;h=108bbca677f58f820cf8ab8653fc41b25ce6436f
Fixed occasional segfault when flipping pages very quickly.
---
diff --git a/src/qdjvuwidget.cpp b/src/qdjvuwidget.cpp
index 7635b52..281d12b 100644
--- a/src/qdjvuwidget.cpp
+++ b/src/qdjvuwidget.cpp
@@ -1711,14 +1711,17 @@ QDjVuPrivate::updatePosition(const QPoint &point, bool click, bool links)
return;
// emit pointerposition signal
PageInfo info;
- Page *p = pageMap[pos.pageNo];
- info.pageno = pos.pageNo;
- info.width = p->width;
- info.height = p->height;
- info.dpi = p->dpi;
- info.segment = widget->getSegmentForRect(selectedRect, info.pageno);
- info.selected = selectedRect;
- emit widget->pointerPosition(pos, info);
+ Page *p = pageMap.value(pos.pageNo,0);
+ if (p != 0)
+ {
+ info.pageno = pos.pageNo;
+ info.width = p->width;
+ info.height = p->height;
+ info.dpi = p->dpi;
+ info.segment = widget->getSegmentForRect(selectedRect, info.pageno);
+ info.selected = selectedRect;
+ emit widget->pointerPosition(pos, info);
+ }
// check mapareas
if (links)
checkCurrentMapArea();
@@ -5255,16 +5258,16 @@ QDjVuWidget::nextPage(void)
int pageNo = page();
const QRect &dr = priv->deskRect;
const QRect &vr = priv->visibleRect;
- const QRect &cr = priv->pageMap[pageNo]->rect;
+ const Page *pg = priv->pageMap.value(pageNo,0);
while (pageNo < priv->numPages - 1)
{
pageNo += 1;
- if (priv->layoutChange || !priv->pageMap.contains(pageNo))
+ if (priv->layoutChange || !priv->pageMap.contains(pageNo) || !pg)
break;
// Skip pages until we get a meaningful change.
const QRect &pr = priv->pageMap[pageNo]->rect;
if (! vr.contains(pr))
- if (pr.top() != cr.top() || vr.width() < dr.width())
+ if (pr.top() != pg->rect.top() || vr.width() < dr.width())
break;
}
setPage(pageNo);
@@ -5277,16 +5280,16 @@ QDjVuWidget::prevPage(void)
int pageNo = page();
const QRect &dr = priv->deskRect;
const QRect &vr = priv->visibleRect;
- const QRect &cr = priv->pageMap[pageNo]->rect;
+ const Page *pg = priv->pageMap.value(pageNo,0);
while (pageNo > 0)
{
pageNo -= 1;
- if (priv->layoutChange || !priv->pageMap.contains(pageNo))
+ if (priv->layoutChange || !priv->pageMap.contains(pageNo) || !pg)
break;
// Skip pages until we get a meaningful change.
const QRect &pr = priv->pageMap[pageNo]->rect;
if (! vr.contains(pr))
- if (pr.top() != cr.top() || vr.width() < dr.width())
+ if (pr.top() != pg->rect.top() || vr.width() < dr.width())
break;
}
setPage(pageNo);
|