mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-03-01 18:29:16 +01:00
OP-60 : avoid crashes when the master SVG is corrupted or simply not a SVG file.
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@977 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
08b27b7549
commit
13168b6b4c
@ -44,7 +44,9 @@ DialGadgetWidget::DialGadgetWidget(QWidget *parent) : QGraphicsView(parent)
|
||||
obj1 = NULL;
|
||||
obj2 = NULL;
|
||||
obj3 = NULL;
|
||||
m_text1 = NULL; // Should be initialized to NULL otherwise the setFont method
|
||||
m_text1 = NULL;
|
||||
m_text2 = NULL;
|
||||
m_text3 = NULL; // Should be initialized to NULL otherwise the setFont method
|
||||
// might segfault upon initialization if called before SetDialFile
|
||||
|
||||
needle1Target = 0;
|
||||
@ -161,10 +163,7 @@ void DialGadgetWidget::setDialFile(QString dfn, QString bg, QString fg, QString
|
||||
n2enabled = false;
|
||||
n3enabled = false;
|
||||
QGraphicsScene *l_scene = scene();
|
||||
if (QFile::exists(dfn))
|
||||
{
|
||||
m_renderer->load(dfn);
|
||||
if(m_renderer->isValid())
|
||||
if (QFile::exists(dfn) && m_renderer->load(dfn) && m_renderer->isValid())
|
||||
{
|
||||
l_scene->clear(); // This also deletes all items contained in the scene.
|
||||
m_background = new QGraphicsSvgItem();
|
||||
@ -336,7 +335,7 @@ void DialGadgetWidget::setDialFile(QString dfn, QString bg, QString fg, QString
|
||||
needle3Value = 0;
|
||||
if (!dialTimer.isActive())
|
||||
dialTimer.start();
|
||||
}
|
||||
dialError = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -347,6 +346,13 @@ void DialGadgetWidget::setDialFile(QString dfn, QString bg, QString fg, QString
|
||||
m_background->setSharedRenderer(m_renderer);
|
||||
m_background->setElementId(bg);
|
||||
l_scene->addItem(m_background);
|
||||
m_text1 = NULL;
|
||||
m_text2 = NULL;
|
||||
m_text3 = NULL;
|
||||
m_needle1 = NULL;
|
||||
m_needle2 = NULL;
|
||||
m_needle3 = NULL;
|
||||
dialError = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -452,6 +458,11 @@ void DialGadgetWidget::setNeedle3(double value) {
|
||||
// to the same element.
|
||||
void DialGadgetWidget::rotateNeedles()
|
||||
{
|
||||
if (dialError) {
|
||||
// We get there in case the dial file is missing or corrupt.
|
||||
dialTimer.stop();
|
||||
return;
|
||||
}
|
||||
int dialRun = 3;
|
||||
if (n2enabled) {
|
||||
double needle2Diff;
|
||||
|
@ -96,6 +96,7 @@ private:
|
||||
bool n3enabled;
|
||||
bool n2enabled; // Simple flag to skip rendering if the
|
||||
bool fgenabled; // layer does not exist.
|
||||
bool dialError ;
|
||||
|
||||
// Settings concerning move of the dials
|
||||
bool rotateN1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user