Skip to content

Commit

Permalink
fixed crash on style rename
Browse files Browse the repository at this point in the history
Milestone reached: first really usable version :)
  • Loading branch information
kermitfrog committed Jul 13, 2016
1 parent 1df5ba1 commit d822383
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions stylemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,16 @@ QColor StyleModel::getColor(QString name, int role)
{
if (name == "")
return getColor("default", role);
if (!styles.contains(name)) {
qDebug() << "no style named " << name;
return QColor();
}
if (role == Qt::ForegroundRole)
return styles[name]->fg.color();
else
else if (role == Qt::BackgroundRole)
return styles[name]->bg.color();
else
qDebug() << "WTF???";
}

void StyleModel::deleteStyle(Style* style)
Expand All @@ -131,8 +137,7 @@ void StyleModel::deleteStyle(QString style)

bool StyleModel::styleChangedOk(Style* style)
{
qDebug() << style->toString();
if (styles[style->name] == style) {
if (styles.value(style->name) == style) {
if (!surpressSignals)
emit stylesChanged(StyleModel::Edit, style);
return true;
Expand All @@ -145,7 +150,7 @@ bool StyleModel::styleChangedOk(Style* style)

QString name = stylesByPointer.take(style);
styles.remove(name);
styles[name] = style;
styles[style->name] = style;
stylesByPointer[style] = name;
if (!surpressSignals)
emit stylesChanged(StyleModel::Name, style);
Expand Down

0 comments on commit d822383

Please sign in to comment.