Skip to content

Commit 1275b4f

Browse files
committed
fix segfault on exit, some UI fixes
1 parent 1775cb5 commit 1275b4f

File tree

3 files changed

+33
-11
lines changed

3 files changed

+33
-11
lines changed

qml/pages/MainPage.qml

+21-6
Original file line numberDiff line numberDiff line change
@@ -89,17 +89,22 @@ Page {
8989
enabled: idle
9090

9191
Image {
92-
anchors.fill: parent
92+
anchors {
93+
top: label1.bottom
94+
left: parent.left
95+
right: parent.right
96+
}
9397
fillMode: Image.Pad
9498
horizontalAlignment: Image.AlignHCenter
95-
verticalAlignment: Image.AlignVCenter
9699
source: "image://theme/icon-m-camera"
97100
scale: 1.5
98101
z: 30
99102
}
100103

101104
Label {
105+
id: label1
102106
anchors.topMargin: 10;
107+
anchors.bottomMargin: 10;
103108
anchors.top: parent.top
104109
width: parent.width
105110
horizontalAlignment: Text.AlignHCenter
@@ -123,16 +128,21 @@ Page {
123128
enabled: idle
124129

125130
Image {
126-
anchors.fill: parent
131+
anchors {
132+
top: label2.bottom
133+
left: parent.left
134+
right: parent.right
135+
}
127136
fillMode: Image.Pad
128137
horizontalAlignment: Image.AlignHCenter
129-
verticalAlignment: Image.AlignVCenter
130138
source: "image://theme/icon-l-image"
131139
z: 30
132140
}
133141

134142
Label {
143+
id: label2
135144
anchors.topMargin: 10;
145+
anchors.bottomMargin: 10;
136146
anchors.top: parent.top
137147
width: parent.width
138148
horizontalAlignment: Text.AlignHCenter
@@ -174,16 +184,21 @@ Page {
174184
enabled: idle
175185

176186
Image {
177-
anchors.fill: parent
187+
anchors {
188+
top: label3.bottom
189+
left: parent.left
190+
right: parent.right
191+
}
178192
fillMode: Image.Pad
179193
horizontalAlignment: Image.AlignHCenter
180-
verticalAlignment: Image.AlignVCenter
181194
source: "image://theme/icon-l-document"
182195
z: 30
183196
}
184197

185198
Label {
199+
id: label3
186200
anchors.topMargin: 10;
201+
anchors.bottomMargin: 10;
187202
anchors.top: parent.top
188203
width: parent.width
189204
horizontalAlignment: Text.AlignHCenter

src/tesseractapi.cpp

+11-5
Original file line numberDiff line numberDiff line change
@@ -35,23 +35,27 @@ TesseractAPI::TesseractAPI(QObject *parent) :
3535

3636
info_ = Info();
3737
cancel_ = false;
38+
run_at_least_once_ = false;
3839
}
3940

4041
TesseractAPI::~TesseractAPI()
4142
{
42-
delete monitor_;
43-
monitor_ = 0;
4443
delete settingsManager_;
4544
settingsManager_ = 0;
4645
delete downloadManager_;
4746
downloadManager_ = 0;
4847
delete timer_;
4948
timer_ = 0;
49+
5050
delete PDFhandler_;
5151
PDFhandler_ = 0;
52-
api_->End();
53-
delete api_;
54-
api_ = 0;
52+
53+
delete monitor_;
54+
monitor_ = 0;
55+
if(run_at_least_once_) {
56+
api_->End();
57+
api_ = 0;
58+
}
5559
}
5660

5761
void TesseractAPI::prepareForCropping(QString imagepath, int rotation, bool gallery) {
@@ -89,6 +93,7 @@ void TesseractAPI::analyze(QString imagepath, QVariant cropPoints)
8993
// Periodically firing timer to get progress reports to the UI.
9094
connect(timer_, SIGNAL(timeout()), this, SLOT(update()));
9195
timer_->start(250);
96+
run_at_least_once_ = true;
9297
}
9398

9499
PDFThumbnailProvider *TesseractAPI::getThumbnailProvider() {
@@ -133,6 +138,7 @@ void TesseractAPI::analyzePDF(QList<int> pages)
133138
// Periodically firing timer to get progress reports to the UI.
134139
connect(timer_, SIGNAL(timeout()), this, SLOT(update()));
135140
timer_->start(250);
141+
run_at_least_once_ = true;
136142
}
137143

138144
void TesseractAPI::cancel()

src/tesseractapi.h

+1
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ public slots:
9797
QString rotatedPath_;
9898
bool rotated_;
9999
bool thumbsReady_;
100+
bool run_at_least_once_;
100101
unsigned int previousPage_;
101102

102103
ETEXT_DESC *monitor_;

0 commit comments

Comments
 (0)