diff options
author | Miikka Heikkinen <miikka.heikkinen@qt.io> | 2018-02-16 14:39:23 +0200 |
---|---|---|
committer | Tomi Korpipää <tomi.korpipaa@qt.io> | 2018-02-19 05:24:43 +0000 |
commit | 1fd71e93b47df854f3c550190f2bbbf3969c989d (patch) | |
tree | 2dbc296217f7f06d826b9225f778d948921d267c | |
parent | 14a03d807f0fee33f194c394258c3f9a59863180 (diff) |
Fix crash when changing datainput for text element
Data input connection always used the handle and instance values that
were used when the connection was established. Also changed it so that
callback from selection dialog only comes when user changes the
selection instead of getting one during dialog setup.
Task-number: QT3DS-1056
Change-Id: Ic4d6bf78ebba5859f55c69f946bc10d7b8154a06
Reviewed-by: Janne Kangas <janne.kangas@qt.io>
Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
7 files changed, 27 insertions, 13 deletions
diff --git a/src/Authoring/Studio/Application/DataInputSelectDlg.cpp b/src/Authoring/Studio/Application/DataInputSelectDlg.cpp index 9586b97c..6642e04b 100644 --- a/src/Authoring/Studio/Application/DataInputSelectDlg.cpp +++ b/src/Authoring/Studio/Application/DataInputSelectDlg.cpp @@ -40,8 +40,11 @@ DataInputSelectDlg::DataInputSelectDlg(QWidget *parent) } void DataInputSelectDlg::setData(const QStringList &dataInputList, - const QString ¤tController) + const QString ¤tController, + int handle, int instance) { + m_handle = handle; + m_instance = instance; clear(); setObjectName("DataInputSelectDlg"); setSelectionMode(QAbstractItemView::SingleSelection); @@ -85,8 +88,9 @@ void DataInputSelectDlg::onItemClicked(QListWidgetItem *item) void DataInputSelectDlg::onSelectionChanged() { - if (currentItem()) { - Q_EMIT dataInputChanged(currentItem()->text()); + // Ignore selection changes that happen during setData + if (currentItem() && isVisible()) { + Q_EMIT dataInputChanged(m_handle, m_instance, currentItem()->text()); hide(); } } diff --git a/src/Authoring/Studio/Application/DataInputSelectDlg.h b/src/Authoring/Studio/Application/DataInputSelectDlg.h index 10d558f3..b4c9e6fd 100644 --- a/src/Authoring/Studio/Application/DataInputSelectDlg.h +++ b/src/Authoring/Studio/Application/DataInputSelectDlg.h @@ -37,14 +37,19 @@ public: explicit DataInputSelectDlg(QWidget *parent = nullptr); void showDialog(const QPoint &point); void setData(const QStringList &dataInputList, - const QString ¤tController); + const QString ¤tController, + int handle = 0, int instance = 0); Q_SIGNALS: - void dataInputChanged(const QString &selected); + void dataInputChanged(int handle, int instance, const QString &selected); protected: void onSelectionChanged(); void onItemClicked(QListWidgetItem *item); + +private: + int m_handle = 0; + int m_instance = 0; }; #endif // DATAINPUTSELECTDLG_H diff --git a/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp b/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp index dda980be..d7ecf893 100644 --- a/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp +++ b/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp @@ -482,8 +482,7 @@ void InspectorControlView::showDataInputChooser(int handle, int instance, const if (!m_dataInputChooserView) { m_dataInputChooserView = new DataInputSelectDlg(g_StudioApp.m_pMainWnd); connect(m_dataInputChooserView, &DataInputSelectDlg::dataInputChanged, this, - [this, handle, instance](const QString &controllerName) { - + [this](int handle, int instance, const QString &controllerName) { bool controlled = controllerName == tr("[No control]") ? false : true; m_inspectorControlModel ->setPropertyControllerInstance( @@ -499,8 +498,8 @@ void InspectorControlView::showDataInputChooser(int handle, int instance, const for (int i = 0; i < g_StudioApp.m_dataInputDialogItems.size(); i++) dataInputList.append(g_StudioApp.m_dataInputDialogItems[i]->name); - m_dataInputChooserView->setData(dataInputList, - m_inspectorControlModel->getCurrentController()); + m_dataInputChooserView->setData(dataInputList, m_inspectorControlModel->getCurrentController(), + handle, instance); m_dataInputChooserView->showDialog(point); } diff --git a/src/Authoring/Studio/Palettes/Slide/SlideView.cpp b/src/Authoring/Studio/Palettes/Slide/SlideView.cpp index c53b120c..e21cb5cd 100644 --- a/src/Authoring/Studio/Palettes/Slide/SlideView.cpp +++ b/src/Authoring/Studio/Palettes/Slide/SlideView.cpp @@ -243,8 +243,11 @@ void SlideView::OnSlideRearranged(const qt3dsdm::Qt3DSDMSlideHandle &inMaster, i m_SlidesModel->onSlideRearranged(inMaster, inOldIndex, inNewIndex); } -void SlideView::onDataInputChange(const QString &dataInputName) +void SlideView::onDataInputChange(int handle, int instance, const QString &dataInputName) { + Q_UNUSED(handle) + Q_UNUSED(instance) + if (dataInputName == m_currentController || (dataInputName == tr("[No Control]") && !m_currentController.size())) { return; diff --git a/src/Authoring/Studio/Palettes/Slide/SlideView.h b/src/Authoring/Studio/Palettes/Slide/SlideView.h index 12594637..fcfbcff0 100644 --- a/src/Authoring/Studio/Palettes/Slide/SlideView.h +++ b/src/Authoring/Studio/Palettes/Slide/SlideView.h @@ -64,7 +64,7 @@ public: void setShowMasterSlide(bool show); QAbstractItemModel *currentModel() { return m_CurrentModel; } QSize sizeHint() const override; - void onDataInputChange(const QString &dataInputName); + void onDataInputChange(int handle, int instance, const QString &dataInputName); Q_INVOKABLE void deselectAll(); Q_INVOKABLE void addNewSlide(int row); diff --git a/src/Authoring/Studio/_Win/UI/TimeLineToolbar.cpp b/src/Authoring/Studio/_Win/UI/TimeLineToolbar.cpp index f0bb7d2c..3d4e435d 100644 --- a/src/Authoring/Studio/_Win/UI/TimeLineToolbar.cpp +++ b/src/Authoring/Studio/_Win/UI/TimeLineToolbar.cpp @@ -214,8 +214,11 @@ void TimeLineToolbar::showDataInputChooser() return; } -void TimeLineToolbar::onDataInputChange(const QString &dataInputName) +void TimeLineToolbar::onDataInputChange(int handle, int instance, const QString &dataInputName) { + Q_UNUSED(handle) + Q_UNUSED(instance) + if (dataInputName == m_currController || (dataInputName == tr("[No Control]") && !m_currController.size())) { return; diff --git a/src/Authoring/Studio/_Win/UI/TimeLineToolbar.h b/src/Authoring/Studio/_Win/UI/TimeLineToolbar.h index 238f9349..75e51c5e 100644 --- a/src/Authoring/Studio/_Win/UI/TimeLineToolbar.h +++ b/src/Authoring/Studio/_Win/UI/TimeLineToolbar.h @@ -56,7 +56,7 @@ public: void OnSelectionChange(Q3DStudio::SSelectedValue newSelectable); void showDataInputChooser(); - void onDataInputChange(const QString &dataInputName); + void onDataInputChange(int handle, int instance, const QString &dataInputName); QSize sizeHint() const; |