Skip to content

Commit ed6a8f5

Browse files
committed
Fix bugs
1 parent 3d8a3e5 commit ed6a8f5

File tree

14 files changed

+61
-44
lines changed

14 files changed

+61
-44
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cmake_minimum_required(VERSION 3.5) # 2.2 - case insensitive syntax
22

3-
project(ModbusTools VERSION 0.3.0 LANGUAGES CXX)
3+
project(ModbusTools VERSION 0.3.1 LANGUAGES CXX)
44

55
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")
66
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")

bugfix.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,9 @@ Fixed a crash bug for the 'readCoils' and 'readDiscreteInputs' functions when th
3131

3232
# 0.2.2
3333

34-
Fix Action value updates - Not Following Defined Register and Byte Order
34+
Fix Action value updates - Not Following Defined Register and Byte Order
35+
36+
# 0.3.1
37+
38+
* Fix bug of client/server crash when create/open project
39+
* Fix bug of client/server when change port settings it doesn't reflect in port name in status bar

changelog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,8 @@
4848
* Add possibility to save DataViewItem values in values when saving project for Client
4949
* Upgrade status bar with Tx/Rx statistic
5050
* Add `Copy` action type
51+
52+
# 0.3.1
53+
54+
* Make project builder more tolerant for unexpected attribute or element
55+
* Fixed bugs

src/client/win_resource.rc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
IDI_ICON1 ICON DISCARDABLE "gui\\icons\\client.ico"
44

55
VS_VERSION_INFO VERSIONINFO
6-
FILEVERSION 0,3,0,0
7-
PRODUCTVERSION 0,3,0,0
6+
FILEVERSION 0,3,1,0
7+
PRODUCTVERSION 0,3,1,0
88
FILEFLAGSMASK 0x3fL
99
#ifdef _DEBUG
1010
FILEFLAGS VS_FF_DEBUG
@@ -21,11 +21,11 @@ VS_VERSION_INFO VERSIONINFO
2121
BEGIN
2222
VALUE "CompanyName", "\0"
2323
VALUE "FileDescription", "\0"
24-
VALUE "FileVersion", "0.3.0.0\0"
24+
VALUE "FileVersion", "0.3.1.0\0"
2525
VALUE "LegalCopyright", "\0"
2626
VALUE "OriginalFilename", "client.exe\0"
2727
VALUE "ProductName", "client\0"
28-
VALUE "ProductVersion", "0.3.0.0\0"
28+
VALUE "ProductVersion", "0.3.1.0\0"
2929
END
3030
END
3131
BLOCK "VarFileInfo"

src/core/gui/core_ui.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -765,20 +765,16 @@ void mbCoreUi::currentPortChanged(mbCorePort *port)
765765
old->disconnect(this);
766766
m_currentPort = port;
767767
refreshCurrentPortName();
768-
mbCorePort::Statistic stat = port->statistic();
768+
mbCorePort::Statistic stat;
769769
if (port)
770770
{
771771
connect(port, &mbCorePort::changed , this, &mbCoreUi::refreshCurrentPortName);
772772
connect(port, &mbCorePort::statCountTxChanged, this, &mbCoreUi::setStatTx );
773773
connect(port, &mbCorePort::statCountRxChanged, this, &mbCoreUi::setStatRx );
774-
setStatTx(stat.countTx);
775-
setStatRx(stat.countRx);
776-
}
777-
else
778-
{
779-
setStatTx(stat.countTx);
780-
setStatRx(stat.countRx);
774+
stat = port->statistic();
781775
}
776+
setStatTx(stat.countTx);
777+
setStatRx(stat.countRx);
782778
}
783779

784780
void mbCoreUi::refreshCurrentPortName()

src/core/project/core_dom.cpp

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,21 @@
2424

2525
#include "core_dataview.h"
2626

27-
mbCoreDom::~mbCoreDom()
27+
void mbCoreXmlStreamReader::raiseWarning(const QString &text)
2828
{
29+
m_warnings.append(QString("Warning (row=%1, column=%2): %3").arg(QString::number(this->lineNumber()),
30+
QString::number(this->columnNumber()),
31+
text));
2932
}
3033

31-
void mbCoreXmlStreamReader::raiseWarning(const QString &text)
34+
void mbCoreXmlStreamReader::processUnexpectedElement(const QString &name)
35+
{
36+
raiseWarning(QString("Unexpected element '%1'").arg(name));
37+
skipCurrentElement();
38+
}
39+
40+
mbCoreDom::~mbCoreDom()
3241
{
33-
m_warnings.append(QString("Warning (row=%1, column=%2): '%3'").arg(QString::number(this->lineNumber()),
34-
QString::number(this->columnNumber()),
35-
text));
3642
}
3743

3844
// -----------------------------------------------------------------------------------------------------------------------
@@ -66,7 +72,7 @@ void mbCoreDomDataViewItem::read(mbCoreXmlStreamReader &reader)
6672
Q_FOREACH (const QXmlStreamAttribute &attribute, reader.attributes())
6773
{
6874
QStringRef name = attribute.name();
69-
reader.raiseError(QStringLiteral("Unexpected attribute ") + name.toString());
75+
reader.raiseWarning(QString("Unexpected attribute '%1'").arg(name.toString()));
7076
}
7177

7278
for (bool finished = false; !finished && !reader.hasError();)
@@ -163,7 +169,7 @@ void mbCoreDomDataView::read(mbCoreXmlStreamReader &reader)
163169
setPeriod(attribute.value().toInt());
164170
continue;
165171
}
166-
reader.raiseError(QStringLiteral("Unexpected attribute ") + name.toString());
172+
reader.raiseWarning(QString("Unexpected attribute '%1'").arg(name.toString()));
167173
}
168174

169175
for (bool finished = false; !finished && !reader.hasError();)
@@ -180,7 +186,7 @@ void mbCoreDomDataView::read(mbCoreXmlStreamReader &reader)
180186
m_items.append(item);
181187
continue;
182188
}
183-
reader.raiseError(QStringLiteral("Unexpected element ") + tag);
189+
reader.processUnexpectedElement(tag);
184190
}
185191
break;
186192
case mbCoreXmlStreamReader::EndElement :
@@ -245,7 +251,7 @@ void mbCoreDomDevice::read(mbCoreXmlStreamReader &reader)
245251
QStringRef name = attribute.name();
246252
if (readAttribute(reader, attribute))
247253
continue;
248-
reader.raiseError(QStringLiteral("Unexpected attribute ") + name.toString());
254+
reader.raiseWarning(QString("Unexpected attribute '%1'").arg(name.toString()));
249255
}
250256

251257
for (bool finished = false; !finished && !reader.hasError();)
@@ -341,7 +347,7 @@ void mbCoreDomPort::read(mbCoreXmlStreamReader &reader)
341347
QStringRef name = attribute.name();
342348
if (readAttribute(reader, attribute))
343349
continue;
344-
reader.raiseError(QStringLiteral("Unexpected attribute ") + name.toString());
350+
reader.raiseWarning(QString("Unexpected attribute '%1'").arg(name.toString()));
345351
}
346352

347353
for (bool finished = false; !finished && !reader.hasError();)
@@ -447,7 +453,7 @@ void mbCoreDomTaskInfo::read(mbCoreXmlStreamReader &reader)
447453
setType(attribute.value().toString());
448454
continue;
449455
}
450-
reader.raiseError(QStringLiteral("Unexpected attribute ") + name.toString());
456+
reader.raiseWarning(QString("Unexpected attribute '%1'").arg(name.toString()));
451457
}
452458

453459
for (bool finished = false; !finished && !reader.hasError();)
@@ -590,8 +596,7 @@ void mbCoreDomProject::read(mbCoreXmlStreamReader &reader)
590596
}
591597
if (readElement(reader, tag))
592598
continue;
593-
reader.skipCurrentElement();
594-
reader.raiseWarning(QStringLiteral("Unexpected element ") + tag);
599+
reader.processUnexpectedElement(tag);
595600
}
596601
break;
597602
case mbCoreXmlStreamReader::EndElement :

src/core/project/core_dom.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ class MB_EXPORT mbCoreXmlStreamReader : public QXmlStreamReader
3939
inline int warningCount() const { return m_warnings.count(); }
4040
inline QStringList warnings() const { return m_warnings; }
4141
void raiseWarning(const QString &text);
42+
void processUnexpectedElement(const QString &name);
4243

4344
protected:
4445
QStringList m_warnings;

src/core/project/core_port.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ bool mbCorePort::setSettings(const MBSETTINGS &settings)
244244
if (ok)
245245
setTimeoutInterByte(v);
246246
}
247-
247+
Q_EMIT changed();
248248
return true;
249249
}
250250

src/core/project/core_port.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ class MB_EXPORT mbCorePort : public QObject
5454

5555
struct Statistic
5656
{
57+
Statistic()
58+
{
59+
countTx = 0;
60+
countRx = 0;
61+
}
5762
quint32 countTx;
5863
quint32 countRx;
5964
};

src/core/sdk/mbcore_config.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@
1414
/*
1515
Patch part of mbtools version
1616
*/
17-
#define MBTOOLS_VERSION_PATCH 0
17+
#define MBTOOLS_VERSION_PATCH 1
1818

1919
#endif // MBCORE_CONFIG_H

0 commit comments

Comments
 (0)