diff options
author | Florian Jung <flo@windfisch.org> | 2011-08-29 16:28:08 +0000 |
---|---|---|
committer | Florian Jung <flo@windfisch.org> | 2011-08-29 16:28:08 +0000 |
commit | 6ea4a4959526136957b7e0d8ae1ebb29e48993ce (patch) | |
tree | fecb6a7b1a9a0372cfcf9a2c04a0f4636c9cb72c /muse2/muse/arranger/pcanvas.cpp | |
parent | cb4ae0b104084e9c054d2a1b28ce531d104e9d76 (diff) |
fixed robert's fixes
Diffstat (limited to 'muse2/muse/arranger/pcanvas.cpp')
-rw-r--r-- | muse2/muse/arranger/pcanvas.cpp | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/muse2/muse/arranger/pcanvas.cpp b/muse2/muse/arranger/pcanvas.cpp index 1bf7a541..572492d6 100644 --- a/muse2/muse/arranger/pcanvas.cpp +++ b/muse2/muse/arranger/pcanvas.cpp @@ -16,13 +16,13 @@ #include <map> #include <QClipboard> +#include <QLineEdit> #include <QMenu> #include <QMessageBox> #include <QPainter> #include <QUrl> #include <QPoint> -#include <awl/lineedit.h> #include "fastlog.h" #include "widgets/tools.h" #include "arranger.h" @@ -154,15 +154,19 @@ void PartCanvas::leaveEvent(QEvent*) void PartCanvas::returnPressed() { lineEditor->hide(); - Part* oldPart = editPart->part(); - Part* newPart = oldPart->clone(); - //printf("PartCanvas::returnPressed before msgChangePart oldPart refs:%d Arefs:%d newPart refs:%d Arefs:%d\n", oldPart->events()->refCount(), oldPart->events()->arefCount(), newPart->events()->refCount(), newPart->events()->arefCount()); - - newPart->setName(lineEditor->text()); - // Indicate do undo, and do port controller values but not clone parts. - audio->msgChangePart(oldPart, newPart, true, true, false); - - editMode = false; + if (editMode) { + //this check is neccessary, because it returnPressed may be called + //twice. the second call would cause a crash, however! + Part* oldPart = editPart->part(); + Part* newPart = oldPart->clone(); + //printf("PartCanvas::returnPressed before msgChangePart oldPart refs:%d Arefs:%d newPart refs:%d Arefs:%d\n", oldPart->events()->refCount(), oldPart->events()->arefCount(), newPart->events()->refCount(), newPart->events()->arefCount()); + + newPart->setName(lineEditor->text()); + // Indicate do undo, and do port controller values but not clone parts. + audio->msgChangePart(oldPart, newPart, true, true, false); + + editMode = false; + } } //--------------------------------------------------------- @@ -183,9 +187,9 @@ void PartCanvas::viewMouseDoubleClickEvent(QMouseEvent* event) editPart = (NPart*)curItem; QRect r = map(curItem->bbox()); if (lineEditor == 0) { - lineEditor = new LineEdit(this); - connect(lineEditor, SIGNAL(returnPressed()),SLOT(returnPressed())); + lineEditor = new QLineEdit(this); lineEditor->setFrame(true); + connect(lineEditor, SIGNAL(editingFinished()),SLOT(returnPressed())); } editMode = true; lineEditor->setGeometry(r); @@ -686,9 +690,9 @@ void PartCanvas::itemPopup(CItem* item, int n, const QPoint& pt) editPart = npart; QRect r = map(curItem->bbox()); if (lineEditor == 0) { - lineEditor = new LineEdit(this); - connect(lineEditor, SIGNAL(returnPressed()),SLOT(returnPressed())); + lineEditor = new QLineEdit(this); lineEditor->setFrame(true); + connect(lineEditor, SIGNAL(editingFinished()),SLOT(returnPressed())); } lineEditor->setText(editPart->name()); lineEditor->setFocus(); @@ -930,7 +934,7 @@ void PartCanvas::keyPress(QKeyEvent* event) { if ( key == Qt::Key_Return || key == Qt::Key_Enter ) { - returnPressed(); + //returnPressed(); commented out by flo return; } else if ( key == Qt::Key_Escape ) |