Skip to content

Commit a2f29d6

Browse files
committed
Fix synchronization of added elements and crash on broken XML on split.
1 parent 624b02a commit a2f29d6

File tree

6 files changed

+29
-18
lines changed

6 files changed

+29
-18
lines changed

CHANGELOG

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
1.6
2+
3+
Improvements:
4+
- update to Qt 5.9
5+
6+
Fixes:
7+
- synchronization broke if new elements were added behind some element (by editing), but the original text element not changed itself
8+
- crash if splitting text with broken XML
9+
10+
111
1.5
212

313
Improvements:

src/ItAlignment.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
/* Copyright (c) 2010-2016 Pavel Vondřička (Pavel.Vondricka@korpus.cz)
2-
* Copyright (c) 2010-2016 Charles University in Prague, Faculty of Arts,
1+
/* Copyright (c) 2010-2017 Pavel Vondřička (Pavel.Vondricka@korpus.cz)
2+
* Copyright (c) 2010-2017 Charles University in Prague, Faculty of Arts,
33
* Institute of the Czech National Corpus
44
*
55
* This file is part of InterText Editor.
@@ -646,13 +646,13 @@ bool ItAlignment::canSplitParent(aligned_doc doc, int pos, int el) {
646646
return true;
647647
}
648648

649-
bool ItAlignment::updateContents(aligned_doc doc, int pos, int el, QString string)
649+
bool ItAlignment::updateContents(aligned_doc doc, int pos, int el, QString string, bool forceupdate)
650650
{
651651
if (!ignorePermissions && ((doc==0 && !info.ver[0].perm_chtext) || (doc==1 && !info.ver[1].perm_chtext))) {
652652
//qDebug() << "Permission denied.";
653653
return false;
654654
}
655-
if (string==getContents(doc,pos,false).toStringList().at(el)) {
655+
if (!forceupdate && string==getContents(doc,pos,false).toStringList().at(el)) {
656656
//qDebug() << "No change, no update.";
657657
return true;
658658
}
@@ -755,7 +755,7 @@ bool ItAlignment::split(aligned_doc doc, int pos, int el, QStringList newstrings
755755
newstrings[i] = newstrings[i].trimmed();
756756
fixBrokenTags(newstrings[i], &inherittags);
757757
}
758-
if (!updateContents(doc, pos, el, newstrings.takeFirst()))
758+
if (!updateContents(doc, pos, el, newstrings.takeFirst(),true))
759759
return false;
760760
while (!newstrings.isEmpty())
761761
if (!duplicate(doc, pos, el++, newstrings.takeFirst()))

src/ItAlignment.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
/* Copyright (c) 2010-2016 Pavel Vondřička (Pavel.Vondricka@korpus.cz)
2-
* Copyright (c) 2010-2016 Charles University in Prague, Faculty of Arts,
1+
/* Copyright (c) 2010-2017 Pavel Vondřička (Pavel.Vondricka@korpus.cz)
2+
* Copyright (c) 2010-2017 Charles University in Prague, Faculty of Arts,
33
* Institute of the Czech National Corpus
44
*
55
* This file is part of InterText Editor.
@@ -160,7 +160,7 @@ class ItAlignment
160160
QVariant getContents(aligned_doc doc, int pos, bool prepend = true, bool ignoreMarkup=false, const QList<Replacement> *transformations=0);
161161
QStringList getIDs(aligned_doc doc, int pos);
162162
int getSize(aligned_doc doc, int pos);
163-
bool updateContents(aligned_doc doc, int pos, int el, QString string);
163+
bool updateContents(aligned_doc doc, int pos, int el, QString string, bool forceupdate=false);
164164
ushort getStat(int pos);
165165
QString getStatName(int pos);
166166
ushort getMark(int pos);

src/ItAlignmentModel.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
/* Copyright (c) 2010-2016 Pavel Vondřička (Pavel.Vondricka@korpus.cz)
2-
* Copyright (c) 2010-2016 Charles University in Prague, Faculty of Arts,
1+
/* Copyright (c) 2010-2017 Pavel Vondřička (Pavel.Vondricka@korpus.cz)
2+
* Copyright (c) 2010-2017 Charles University in Prague, Faculty of Arts,
33
* Institute of the Czech National Corpus
44
*
55
* This file is part of InterText Editor.
@@ -649,6 +649,8 @@ bool ItAlignmentModel::isFirstParEl(QModelIndex index) {
649649
}
650650

651651
bool ItAlignmentModel::remove(QModelIndex index, int count) {
652+
if (!index.isValid() || !index.parent().isValid())
653+
return false;
652654
if (!alignment->removeAfter(index.parent().column()-1, index.parent().row(), index.row()-1, count))
653655
return false;
654656
emit dataChanged(index.parent(), index.parent());

src/ItWindow.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
/* Copyright (c) 2010-2016 Pavel Vondřička (Pavel.Vondricka@korpus.cz)
2-
* Copyright (c) 2010-2016 Charles University in Prague, Faculty of Arts,
1+
/* Copyright (c) 2010-2017 Pavel Vondřička (Pavel.Vondricka@korpus.cz)
2+
* Copyright (c) 2010-2017 Charles University in Prague, Faculty of Arts,
33
* Institute of the Czech National Corpus
44
*
55
* This file is part of InterText Editor.
@@ -909,9 +909,9 @@ void ItWindow::about()
909909
QMessageBox m;
910910
m.setWindowTitle(tr("About InterText"));
911911
m.setIconPixmap(QPixmap(":/images/32/InterText.ico"));
912-
m.setText(tr("<h1>InterText editor 1.5</h1>"));
912+
m.setText(tr("<h1>InterText editor 1.6</h1>"));
913913
m.setInformativeText(tr("<p><b>Alignment editor for parallel texts.</b></p>"
914-
"<p>Copyright &copy; 2010-2016 Pavel Vondřička,<br/>"
914+
"<p>Copyright &copy; 2010-2017 Pavel Vondřička,<br/>"
915915
"Institute of the Czech National Corpus,<br/>"
916916
"Charles University in Prague, Faculty of Arts</p>"
917917
"<p>This software is licensed under the GNU General Public License (Version 3).</p>"));

src/ServerDialog.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
/* Copyright (c) 2010-2016 Pavel Vondřička (Pavel.Vondricka@korpus.cz)
2-
* Copyright (c) 2010-2016 Charles University in Prague, Faculty of Arts,
1+
/* Copyright (c) 2010-2017 Pavel Vondřička (Pavel.Vondricka@korpus.cz)
2+
* Copyright (c) 2010-2017 Charles University in Prague, Faculty of Arts,
33
* Institute of the Czech National Corpus
44
*
55
* This file is part of InterText Editor.
@@ -1702,8 +1702,7 @@ bool ServerDialog::serverRequestUpdate(int aid, ItAlignment * a, aligned_doc d,
17021702
postData.addQueryItem("ver", a->info.ver[d].name);
17031703
postData.addQueryItem("l", QString::number(n));
17041704
postData.addQueryItem("newtext", text);
1705-
postData.addQueryItem("lastsync", a->info.ver[d].synced.toUTC().toString(Qt::ISODate));//qDebug()<<query.encodedQuery();
1706-
//query.setQuery(postData);
1705+
postData.addQueryItem("lastsync", a->info.ver[d].synced.toUTC().toString(Qt::ISODate));
17071706
QEventLoop * loop = new QEventLoop();
17081707
QNetworkReply * reply = net->post(request, postData.query(QUrl::EncodeUnicode).toLatin1());
17091708
connect(reply, SIGNAL(finished()), loop, SLOT(quit()));

0 commit comments

Comments
 (0)