[qet] qet/qet: [4993] Fix crash: In Xref link widget, If there is an element being added (element pose mode), and this one is compatible with the type of Xref sought by the widget, then the widget show this element.

[ Thread Index | Date Index | More lists.tuxfamily.org/qet Archives ]


Revision: 4993
Author:   blacksun
Date:     2017-07-26 10:55:32 +0200 (Wed, 26 Jul 2017)
Log Message:
-----------
Fix crash: In Xref link widget, If there is an element being added (element pose mode), and this one is compatible with the type of Xref sought by the widget, then the widget show this element.
When user finish the element pose mode, the element under the cursor is deleted, but continue to be show by the widget.
So, click on this element in the widget cause a crash.
This case come when user add element and go to another diagram without finish the pose mode, and open Xref link widget from an element in this other diagram. 

Modified Paths:
--------------
    trunk/sources/diagram.cpp
    trunk/sources/diagram.h
    trunk/sources/projectview.cpp
    trunk/sources/projectview.h

Modified: trunk/sources/diagram.cpp
===================================================================
--- trunk/sources/diagram.cpp	2017-07-20 12:40:30 UTC (rev 4992)
+++ trunk/sources/diagram.cpp	2017-07-26 08:55:32 UTC (rev 4993)
@@ -377,8 +377,6 @@
  * Diagram become the ownership of event_interface
  * If there is a previous interface, they will be delete before
  * and call init() to the new interface.
- * The derivated class of DiagramEventInterface need to emit the signal "finish" when the job is done,
- * diagram use this signal to delete the interface. If the signal isn't send, the interface will never be deleted.
  * @param event_interface
  */
 void Diagram::setEventInterface(DiagramEventInterface *event_interface)
@@ -392,6 +390,19 @@
 }
 
 /**
+ * @brief Diagram::clearEventInterface
+ * Clear the current event interface.
+ */
+void Diagram::clearEventInterface()
+{
+	if(m_event_interface)
+	{
+		delete m_event_interface;
+		m_event_interface = nullptr;
+	}
+}
+
+/**
  * @brief Diagram::conductorsAutonumName
  * @return the name of autonum to use.
  */

Modified: trunk/sources/diagram.h
===================================================================
--- trunk/sources/diagram.h	2017-07-20 12:40:30 UTC (rev 4992)
+++ trunk/sources/diagram.h	2017-07-26 08:55:32 UTC (rev 4993)
@@ -129,6 +129,7 @@
 	
 	public:
 		void setEventInterface (DiagramEventInterface *event_interface);
+		void clearEventInterface();
 			
 			//methods related to autonum
 		QString conductorsAutonumName() const;

Modified: trunk/sources/projectview.cpp
===================================================================
--- trunk/sources/projectview.cpp	2017-07-20 12:40:30 UTC (rev 4992)
+++ trunk/sources/projectview.cpp	2017-07-26 08:55:32 UTC (rev 4993)
@@ -989,15 +989,22 @@
  * we display the fallback widget.
  * @param tab_id
  */
-void ProjectView::tabChanged(int tab_id) {
+void ProjectView::tabChanged(int tab_id)
+{
 	if (tab_id == -1)
 		setDisplayFallbackWidget(true);
 	else if(m_tab->count() == 1)
 		setDisplayFallbackWidget(false);
-
+	
 	emit(diagramActivated(m_diagram_ids[tab_id]));
+	
 	if (m_diagram_ids[tab_id] != nullptr)
 		m_diagram_ids[tab_id]->diagram()->diagramActivated();
+
+		//Clear the event interface of the previous diagram
+	if (DiagramView *dv = m_diagram_ids[m_previous_tab_index])
+		dv->diagram()->clearEventInterface();
+	m_previous_tab_index = tab_id;
 }
 
 /**

Modified: trunk/sources/projectview.h
===================================================================
--- trunk/sources/projectview.h	2017-07-20 12:40:30 UTC (rev 4992)
+++ trunk/sources/projectview.h	2017-07-26 08:55:32 UTC (rev 4993)
@@ -133,6 +133,7 @@
 		QLabel *fallback_label_;
 		QTabWidget *m_tab;
 		QMap<int, DiagramView *> m_diagram_ids;
+		int m_previous_tab_index = -1;
 		QList<DiagramView *> m_diagram_view_list;
 };
 


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/