Skip to content

Commit

Permalink
[TASK] do some more consting and fix initializations and SIGSEGV (dev)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonaseberle committed Jun 17, 2023
1 parent 6bceae2 commit 95e05d5
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 26 deletions.
2 changes: 1 addition & 1 deletion src/GLWidget.cpp
Expand Up @@ -681,7 +681,7 @@ void GLWidget::createControllerLists() {
}


void GLWidget::createHoveredControllersLists(QSet<Controller*> controllers) {
void GLWidget::createHoveredControllersLists(const QSet<Controller*>& controllers) {
// make sure all the lists are there to avoid nested glNewList calls
foreach (Controller* c, controllers) {
if (c->sector != 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/GLWidget.h
Expand Up @@ -82,7 +82,7 @@ class GLWidget
void createControllerLists();
void createStaticLists();
void createStaticSectorLists();
void createHoveredControllersLists(QSet<Controller*> controllers);
void createHoveredControllersLists(const QSet<Controller*>& controllers);

void parseTexture();
void createLights();
Expand Down
8 changes: 7 additions & 1 deletion src/MapObject.cpp
Expand Up @@ -4,10 +4,15 @@ MapObject::MapObject()
: QObject(),
lat(0.),
lon(0.),
drawLabel(true) {}
drawLabel(true),
m_label(QString()),
m_toolTip(QString()) {}

MapObject::MapObject(QString label, QString toolTip)
: QObject(),
lat(0.),
lon(0.),
drawLabel(true),
m_label(label),
m_toolTip(toolTip) {}

Expand All @@ -20,6 +25,7 @@ MapObject::MapObject(const MapObject& obj)
lat = obj.lat;
lon = obj.lon;
m_label = obj.m_label;
m_toolTip = obj.m_toolTip;
drawLabel = obj.drawLabel;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Sector.h
Expand Up @@ -39,7 +39,7 @@ class Sector {
QStringList m_controllerSuffixes = QStringList();
QList<QPolygonF> m_nonWrappedPolygons;
QList<QPair<double, double> > m_points;
GLuint _polygon = 0, _borderline = 0, _polygonHighlighted = 0, _borderlineHighlighted = 0;
GLuint _polygon, _borderline, _polygonHighlighted, _borderlineHighlighted;
};

#endif /*SECTOR_H_*/
35 changes: 13 additions & 22 deletions src/models/SearchResultModel.cpp
Expand Up @@ -20,42 +20,33 @@ QVariant SearchResultModel::data(const QModelIndex &index, int role) const {
return QVariant();
}

if (role == Qt::DisplayRole) {
if (role == Qt::DisplayRole || role == Qt::ToolTipRole) {
MapObject* o = _content[index.row()];
if (o == 0) {
return QVariant();
}
switch (index.column()) {
case 0: return o->toolTip(); break;
}
} else if (role == Qt::ToolTipRole) {

return QVariant();
}

if (role == Qt::FontRole) {
QFont result;
MapObject* o = _content[index.row()];
if (o == 0) {
return QVariant();
return result;
}
switch (index.column()) {
case 0: return o->toolTip(); break;
}
} else if (role == Qt::FontRole) {
QFont result;
// prefiled italic
if (dynamic_cast<Pilot*>(_content[index.row()])) {
Pilot* p = dynamic_cast<Pilot*>(_content[index.row()]);
if (p == 0) {
return QVariant();
}
if (p->flightStatus() == Pilot::PREFILED) {
result.setItalic(true);
}
Pilot* p = dynamic_cast<Pilot*>(o);
if (p != 0 && p->flightStatus() == Pilot::PREFILED) {
result.setItalic(true);
}

// friends bold
Client* c = dynamic_cast<Client*>(_content[index.row()]);
if (c == 0) {
return QVariant();
}

if (c->isFriend()) {
Client* c = dynamic_cast<Client*>(o);
if (c != 0 && c->isFriend()) {
result.setBold(true);
}
return result;
Expand Down

0 comments on commit 95e05d5

Please sign in to comment.