Skip to content
This repository was archived by the owner on Aug 26, 2020. It is now read-only.

Commit 6d928bb

Browse files
committed
Fix Region-change Crash
1 parent 011d280 commit 6d928bb

File tree

14 files changed

+60
-50
lines changed

14 files changed

+60
-50
lines changed

docs/RELEASES

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
0.8.8 - Fixes crashes when changing regions due to access of invalidated
2+
logInfo pointers.
3+
14
0.8.7 - Fixed avatars not showing for some users on Windows due to missing
25
DLLs.
36

src/imp.pro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
1212
TARGET = imp
1313
TEMPLATE = app
1414

15-
VERSION = 0.8.7
15+
VERSION = 0.8.8
1616
QMAKE_TARGET_COMPANY = EternalDusk
1717
QMAKE_TARGET_DESCRIPTION = Eve Online Intelligence Management Program
1818
QMAKE_TARGET_COPYRIGHT = (c) Copyright 2016-2017 Jesse Litton

src/mainwindow.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -344,14 +344,7 @@ void MainWindow::loadMap()
344344
regionMap = NULL;
345345
}
346346
regionMap = new Map(this);
347-
348347
ui->mapView->setMap(regionMap);
349-
connect(regionMap, &Map::lineAdded,
350-
ui->mapView, &SvgMapView::gotLine);
351-
connect(regionMap, &Map::systemAdded,
352-
ui->mapView, &SvgMapView::gotSystem);
353-
connect(regionMap, &Map::systemPosition,
354-
ui->mapView, &SvgMapView::gotSystemPosition);
355348

356349
QNetworkRequest request(QUrl(options.getMapPath() +
357350
options.getRegion() + ".svg"));
@@ -648,7 +641,7 @@ void MainWindow::initParsing()
648641
{
649642
parser->deleteLater();
650643
}
651-
parser = new Parser(this);
644+
parser = new Parser(++parserGeneration, this);
652645
parser->setMap(*regionMap);
653646

654647
if(lc != NULL)
@@ -1009,6 +1002,11 @@ void MainWindow::fileChanged(const QString &absoluteFilePath)
10091002

10101003
foreach (MessageInfo message, messages)
10111004
{
1005+
// If they switch regions while parsing messages,
1006+
// discard the ones on the queue.
1007+
if(message.parserGeneration != parserGeneration)
1008+
break;
1009+
10121010
if(!mapLoading)
10131011
doUserActions(message);
10141012

src/mainwindow.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ private slots:
170170

171171
LogCatcher* lc = NULL;
172172
Parser* parser = NULL;
173+
uint parserGeneration = 0;
173174

174175
QNetworkAccessManager manager;
175176
QNetworkReply* reply;

src/map.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,6 @@ Map::Map(QObject *parent) : QObject(parent)
3636
void Map::setRefresh(int msecs)
3737
{
3838
m_timer->setInterval(msecs);
39-
/*
40-
if(m_timer != NULL)
41-
{
42-
m_timer->deleteLater();
43-
}
44-
m_timer = new QTimer(this);
45-
connect(m_timer, SIGNAL(timeout()), this, SLOT(updateActiveSystems()));
46-
*/
4739
}
4840

4941
void Map::startUpdates()

src/mapshape.cpp

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,31 +27,26 @@
2727
#include <QStandardPaths>
2828
#include <QSvgRenderer>
2929

30-
MapShape::MapShape()
30+
MapShape::MapShape(QGraphicsItem *parentItem) : QGraphicsSvgItem(parentItem)
3131
{
32-
renderer = new QSvgRenderer();
33-
connect(renderer, &QSvgRenderer::repaintNeeded,
34-
this, &MapShape::repainter );
3532
}
3633

3734
MapShape::MapShape(QSvgRenderer* svgRenderer,
38-
const QString& name,
39-
const QString& itemId)
35+
QString name,
36+
QString itemId,
37+
QGraphicsItem* parentItem) : QGraphicsSvgItem(parentItem)
4038
{
41-
renderer = svgRenderer;
39+
this->setSharedRenderer(svgRenderer);
40+
4241
shapeName = name;
43-
setSharedRenderer(renderer);
4442
setElementId(itemId);
45-
connect(renderer, &QSvgRenderer::repaintNeeded,
46-
this, &MapShape::repainter);
43+
44+
/*connect(renderer, &QSvgRenderer::repaintNeeded,
45+
this, &MapShape::repainter);*/
4746
}
4847

4948
MapShape::~MapShape()
5049
{
51-
if(renderer != NULL)
52-
{
53-
renderer->deleteLater();
54-
}
5550
}
5651

5752
void MapShape::repainter()
@@ -103,8 +98,7 @@ void MapShape::load(const QString& fileName)
10398

10499
void MapShape::rebuildSvg()
105100
{
106-
renderer->load(domDoc.toByteArray());
107-
setSharedRenderer(renderer);
101+
renderer()->load(domDoc.toByteArray());
108102
setElementId("");
109103

110104
setFlags(QGraphicsItem::ItemClipsToShape);

src/mapshape.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@
3232
class MapShape : public QGraphicsSvgItem
3333
{
3434
public:
35-
explicit MapShape();
35+
explicit MapShape(QGraphicsItem *parentItem = nullptr);
3636
MapShape(QSvgRenderer* svgRenderer,
37-
const QString& name,
38-
const QString& itemId);//,
39-
//QGraphicsView *view);
37+
QString name,
38+
QString itemId,
39+
QGraphicsItem *parentItem = nullptr);
4040
~MapShape();
4141

4242
void paint(QPainter * painter,
@@ -67,7 +67,6 @@ public slots:
6767
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
6868

6969
QString shapeName;
70-
QSvgRenderer* renderer;
7170

7271
private:
7372
bool rotationLocked;

src/meta.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ static const struct Version
2727
{
2828
Version(){}
2929

30-
QString release = "0.8.7"; //VERSION;
31-
QString name = "Lupine Fresh Scent";
30+
QString release = "0.8.8"; //VERSION;
31+
QString name = "Lycrash vs. Silver Pointers";
3232

3333
QString styleHeader1 = "<span style=\" color:#0000ff;\">";
3434
QString styleFooter1 = "</span>";

src/parser.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,10 @@
3232

3333
using namespace std;
3434

35-
Parser::Parser(QObject *parent) : QObject(parent)
35+
Parser::Parser(uint generation, QObject *parent) : QObject(parent)
3636
{
37+
this->generation = generation;
38+
3739
ignoreChars = "[\\\\_=!@#$%^&\\*,\\.\\[\\]\\(\\)\\{\\}\\?]"; // "\\_=!@#$%^&*,./[](){}?"
3840

3941
// Load words, channels, and ships from files
@@ -101,6 +103,7 @@ QList<MessageInfo> Parser::fileChanged(const QString& path, int maxEntries, bool
101103
if (sysIdRegExp.indexIn(line) != -1 && localChannels.contains(channel))
102104
{
103105
MessageInfo systemChange;
106+
systemChange.parserGeneration = generation;
104107
systemChange.flags.append(MessageFlag::SYSTEM_CHANGE);
105108
systemChange.systems.append(regionMap->getSystemById(sysIdRegExp.cap(1)));
106109
systemChange.text = "System changed to " + systemChange.systems[0];
@@ -134,6 +137,7 @@ QList<MessageInfo> Parser::fileChanged(const QString& path, int maxEntries, bool
134137

135138
MessageInfo newMessage = parseLine(lines[i].trimmed().remove(0xfeff));
136139

140+
newMessage.parserGeneration = generation;
137141
newMessage.logInfo = &fileMap[path];
138142
if(newMessage.systems.length() > 0)
139143
{

src/parser.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,9 @@ struct LogInfo
5050

5151
struct MessageInfo
5252
{
53+
uint parserGeneration = 0;
5354
QString originalLine;
54-
bool indecipherable = false;
55+
bool indecipherable = false;
5556

5657
LogInfo* logInfo;
5758

@@ -73,7 +74,7 @@ class Parser : public QObject
7374
{
7475
Q_OBJECT
7576
public:
76-
explicit Parser(QObject *parent = 0);
77+
explicit Parser(uint generation, QObject *parent = 0);
7778
void setMap(Map& map);
7879
QList<MessageInfo> fileChanged(const QString& path, int maxEntries = 0, bool initialLoad = false);
7980
QSet<QString> getLocalChannels();
@@ -87,6 +88,8 @@ class Parser : public QObject
8788
public slots:
8889

8990
private:
91+
uint generation = 0;
92+
9093
QString lastListener;
9194
QString lastLocalSystem;
9295

0 commit comments

Comments
 (0)