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

Commit

Permalink
Fix Region-change Crash
Browse files Browse the repository at this point in the history
  • Loading branch information
3vi1 committed May 26, 2017
1 parent 011d280 commit 6d928bb
Show file tree
Hide file tree
Showing 14 changed files with 60 additions and 50 deletions.
3 changes: 3 additions & 0 deletions docs/RELEASES
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
0.8.8 - Fixes crashes when changing regions due to access of invalidated
logInfo pointers.

0.8.7 - Fixed avatars not showing for some users on Windows due to missing
DLLs.

Expand Down
2 changes: 1 addition & 1 deletion src/imp.pro
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = imp
TEMPLATE = app

VERSION = 0.8.7
VERSION = 0.8.8
QMAKE_TARGET_COMPANY = EternalDusk
QMAKE_TARGET_DESCRIPTION = Eve Online Intelligence Management Program
QMAKE_TARGET_COPYRIGHT = (c) Copyright 2016-2017 Jesse Litton
Expand Down
14 changes: 6 additions & 8 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,14 +344,7 @@ void MainWindow::loadMap()
regionMap = NULL;
}
regionMap = new Map(this);

ui->mapView->setMap(regionMap);
connect(regionMap, &Map::lineAdded,
ui->mapView, &SvgMapView::gotLine);
connect(regionMap, &Map::systemAdded,
ui->mapView, &SvgMapView::gotSystem);
connect(regionMap, &Map::systemPosition,
ui->mapView, &SvgMapView::gotSystemPosition);

QNetworkRequest request(QUrl(options.getMapPath() +
options.getRegion() + ".svg"));
Expand Down Expand Up @@ -648,7 +641,7 @@ void MainWindow::initParsing()
{
parser->deleteLater();
}
parser = new Parser(this);
parser = new Parser(++parserGeneration, this);
parser->setMap(*regionMap);

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

foreach (MessageInfo message, messages)
{
// If they switch regions while parsing messages,
// discard the ones on the queue.
if(message.parserGeneration != parserGeneration)
break;

if(!mapLoading)
doUserActions(message);

Expand Down
1 change: 1 addition & 0 deletions src/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ private slots:

LogCatcher* lc = NULL;
Parser* parser = NULL;
uint parserGeneration = 0;

QNetworkAccessManager manager;
QNetworkReply* reply;
Expand Down
8 changes: 0 additions & 8 deletions src/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,6 @@ Map::Map(QObject *parent) : QObject(parent)
void Map::setRefresh(int msecs)
{
m_timer->setInterval(msecs);
/*
if(m_timer != NULL)
{
m_timer->deleteLater();
}
m_timer = new QTimer(this);
connect(m_timer, SIGNAL(timeout()), this, SLOT(updateActiveSystems()));
*/
}

void Map::startUpdates()
Expand Down
26 changes: 10 additions & 16 deletions src/mapshape.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,31 +27,26 @@
#include <QStandardPaths>
#include <QSvgRenderer>

MapShape::MapShape()
MapShape::MapShape(QGraphicsItem *parentItem) : QGraphicsSvgItem(parentItem)
{
renderer = new QSvgRenderer();
connect(renderer, &QSvgRenderer::repaintNeeded,
this, &MapShape::repainter );
}

MapShape::MapShape(QSvgRenderer* svgRenderer,
const QString& name,
const QString& itemId)
QString name,
QString itemId,
QGraphicsItem* parentItem) : QGraphicsSvgItem(parentItem)
{
renderer = svgRenderer;
this->setSharedRenderer(svgRenderer);

shapeName = name;
setSharedRenderer(renderer);
setElementId(itemId);
connect(renderer, &QSvgRenderer::repaintNeeded,
this, &MapShape::repainter);

/*connect(renderer, &QSvgRenderer::repaintNeeded,
this, &MapShape::repainter);*/
}

MapShape::~MapShape()
{
if(renderer != NULL)
{
renderer->deleteLater();
}
}

void MapShape::repainter()
Expand Down Expand Up @@ -103,8 +98,7 @@ void MapShape::load(const QString& fileName)

void MapShape::rebuildSvg()
{
renderer->load(domDoc.toByteArray());
setSharedRenderer(renderer);
renderer()->load(domDoc.toByteArray());
setElementId("");

setFlags(QGraphicsItem::ItemClipsToShape);
Expand Down
9 changes: 4 additions & 5 deletions src/mapshape.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@
class MapShape : public QGraphicsSvgItem
{
public:
explicit MapShape();
explicit MapShape(QGraphicsItem *parentItem = nullptr);
MapShape(QSvgRenderer* svgRenderer,
const QString& name,
const QString& itemId);//,
//QGraphicsView *view);
QString name,
QString itemId,
QGraphicsItem *parentItem = nullptr);
~MapShape();

void paint(QPainter * painter,
Expand Down Expand Up @@ -67,7 +67,6 @@ public slots:
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);

QString shapeName;
QSvgRenderer* renderer;

private:
bool rotationLocked;
Expand Down
4 changes: 2 additions & 2 deletions src/meta.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ static const struct Version
{
Version(){}

QString release = "0.8.7"; //VERSION;
QString name = "Lupine Fresh Scent";
QString release = "0.8.8"; //VERSION;
QString name = "Lycrash vs. Silver Pointers";

QString styleHeader1 = "<span style=\" color:#0000ff;\">";
QString styleFooter1 = "</span>";
Expand Down
6 changes: 5 additions & 1 deletion src/parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@

using namespace std;

Parser::Parser(QObject *parent) : QObject(parent)
Parser::Parser(uint generation, QObject *parent) : QObject(parent)
{
this->generation = generation;

ignoreChars = "[\\\\_=!@#$%^&\\*,\\.\\[\\]\\(\\)\\{\\}\\?]"; // "\\_=!@#$%^&*,./[](){}?"

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

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

newMessage.parserGeneration = generation;
newMessage.logInfo = &fileMap[path];
if(newMessage.systems.length() > 0)
{
Expand Down
7 changes: 5 additions & 2 deletions src/parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ struct LogInfo

struct MessageInfo
{
uint parserGeneration = 0;
QString originalLine;
bool indecipherable = false;
bool indecipherable = false;

LogInfo* logInfo;

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

private:
uint generation = 0;

QString lastListener;
QString lastLocalSystem;

Expand Down
17 changes: 17 additions & 0 deletions src/svgmapview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,9 @@ void SvgMapView::gotPilotLocation(const QString& pilotName, const QString& syste

void SvgMapView::gotSystemShapesFile(QString shapesFile)
{
qDebug() << "SvgMapView::gotSystemShapesFile(" << shapesFile <<
") - systemRenderer = " << systemRenderer;

if(systemRenderer != NULL)
{
systemRenderer->deleteLater();
Expand Down Expand Up @@ -650,6 +653,8 @@ void SvgMapView::gotSystem(const QString& mixedName, QPointF position, const QSt
{
// TODO: Make a new starSystem item that encapsulates all these components?

qDebug() << "SvgMapView::gotSystem(" << mixedName << "," << position << "," << systemClass << "," << description << ")";

QString name = mixedName.toUpper();
SystemShape* shape = new SystemShape(systemRenderer,
name,
Expand Down Expand Up @@ -701,6 +706,18 @@ void SvgMapView::gotSystemPosition(
setTextPosition(m_texts[name + ":time"], position, timeOffset);
}

void SvgMapView::setMap(Map* m)
{
m_map = m;

connect(m_map, &Map::lineAdded,
this, &SvgMapView::gotLine);
connect(m_map, &Map::systemAdded,
this, &SvgMapView::gotSystem);
connect(m_map, &Map::systemPosition,
this, &SvgMapView::gotSystemPosition);
}

void SvgMapView::setTextPosition(QGraphicsTextItem* ti, QPointF position, QPointF offset)
{
QPointF center = ti->boundingRect().bottomRight() * .5;
Expand Down
2 changes: 1 addition & 1 deletion src/svgmapview.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class SvgMapView : public QGraphicsView
explicit SvgMapView(QWidget *parent = 0);
~SvgMapView();

void setMap(Map* m){m_map = m;}
void setMap(Map* m);

void clearLines();
void clearMap();
Expand Down
8 changes: 3 additions & 5 deletions src/systemshape.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@

SystemShape::SystemShape(QSvgRenderer* svgRenderer,
QString name,
QString c)
: MapShape(svgRenderer, name, c)
QString c,
QGraphicsItem *parentItem)
: MapShape(svgRenderer, name, c, parentItem)
{
shapeName = name + ":system";
className = c;

// renderer = svgRenderer;
// setSharedRenderer(renderer);
// setElementId(className);
setFlags(QGraphicsItem::ItemClipsToShape);
setZValue(0);
setGraphicsEffect(0);
Expand Down
3 changes: 2 additions & 1 deletion src/systemshape.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ class SystemShape : public MapShape
public:
SystemShape(QSvgRenderer* svgRenderer,
QString name,
QString className);
QString className,
QGraphicsItem *parentItem = nullptr);
~SystemShape();

void setColor(const QColor& c);
Expand Down

0 comments on commit 6d928bb

Please sign in to comment.