Skip to content

Commit

Permalink
Fixed potential crash when opening a new project
Browse files Browse the repository at this point in the history
  • Loading branch information
lindvalla committed Apr 25, 2014
1 parent 87fc515 commit a4baeb0
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
10 changes: 3 additions & 7 deletions app/generator/uianaloggenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ void UiAnalogGenerator::handleDeviceChanged()
// We cannot call removeAllSignals here since we would then delete
// signals in the active device.


QList<QMdiSubWindow*> list = mWinArea->subWindowList();
foreach(QMdiSubWindow* win, list) {
closeWindow(win, false);
Expand Down Expand Up @@ -197,6 +196,8 @@ void UiAnalogGenerator::closeWindow(QMdiSubWindow* win, bool removeSignal)

AnalogSignal* signal = editWidget->signal();

editWidget->invalidateSignal();

mWinArea->removeSubWindow(win);

if (removeSignal) {
Expand All @@ -205,12 +206,7 @@ void UiAnalogGenerator::closeWindow(QMdiSubWindow* win, bool removeSignal)

// when deleting win the associated widget (editWidget) will also
// be deleted since win has ownership of editWidget
//delete win;

// 2013-03-28 Commented out the "delete win" line as it causes
// segmentation faults when closing the window every time.
// Problem does not occur in Linux. On Windows it occurs both for
// the device and the simulator.
delete win;
}

/*!
Expand Down
18 changes: 15 additions & 3 deletions app/generator/uieditanalog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,18 @@ UiEditAnalog::UiEditAnalog(AnalogSignal *signal, QWidget *parent) :
*/


/*!
Marks the signal as invalid and disconnects the editor. This is needed
to prevent calls to handleNameEdited() after the AnalogSignal has been
deleted elsewhere.
*/
void UiEditAnalog::invalidateSignal()
{
disconnect(mNameEdit, SIGNAL(editingFinished()),
this, SLOT(handleNameEdited()));
mSignal = NULL;
}

/*!
Creates and returns a box where the analog waveform can be chosen.
The current waveform is set to \a selected.
Expand Down Expand Up @@ -178,10 +190,10 @@ void UiEditAnalog::handleNameEdited()
QString n = mNameEdit->text();
if (n.isEmpty() || n.isNull()) {
n = mSignal->name();
mNameEdit->setText(n);
} else if (mNameEdit->text() != mSignal->name()) {
mSignal->setName(n);
}

mSignal->setName(n);
mNameEdit->setText(n);
}

/*!
Expand Down
1 change: 1 addition & 0 deletions app/generator/uieditanalog.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class UiEditAnalog : public QWidget
explicit UiEditAnalog(AnalogSignal* signal, QWidget *parent = 0);

AnalogSignal* signal() {return mSignal;}
void invalidateSignal();

signals:

Expand Down

0 comments on commit a4baeb0

Please sign in to comment.