[qet] qet/qet: [4959] In rare case in the diagram editor, when we add an element in the diagram and quickly click left, qet crash.

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


Revision: 4959
Author:   blacksun
Date:     2017-05-13 18:01:47 +0200 (Sat, 13 May 2017)
Log Message:
-----------
In rare case in the diagram editor, when we add an element in the diagram and quickly click left, qet crash.
This commit try to avoid this crash, but without any certitude because the crash is very difficult to reproduce

Modified Paths:
--------------
    trunk/sources/diagram.cpp
    trunk/sources/diagramevent/diagrameventinterface.cpp
    trunk/sources/diagramevent/diagrameventinterface.h

Modified: trunk/sources/diagram.cpp
===================================================================
--- trunk/sources/diagram.cpp	2017-05-07 18:54:40 UTC (rev 4958)
+++ trunk/sources/diagram.cpp	2017-05-13 16:01:47 UTC (rev 4959)
@@ -179,7 +179,15 @@
  */
 void Diagram::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
 {
-	if (m_event_interface && m_event_interface->mouseDoubleClickEvent(event)) return;
+	if (m_event_interface)
+		if(m_event_interface->mouseDoubleClickEvent(event))
+		{
+			if(!m_event_interface->isRunning())
+			{
+				delete m_event_interface; m_event_interface = nullptr;
+			}
+			return;
+		}
 
 	QGraphicsScene::mouseDoubleClickEvent(event);
 }
@@ -191,7 +199,15 @@
  */
 void Diagram::mousePressEvent(QGraphicsSceneMouseEvent *event)
 {
-	if (m_event_interface && m_event_interface->mousePressEvent(event)) return;
+	if (m_event_interface)
+		if(m_event_interface->mousePressEvent(event))
+		{
+			if(!m_event_interface->isRunning())
+			{
+				delete m_event_interface; m_event_interface = nullptr;
+			}
+			return;
+		}
 
 	QGraphicsScene::mousePressEvent(event);
 }
@@ -203,7 +219,15 @@
  */
 void Diagram::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
 {
-	if (m_event_interface && m_event_interface->mouseMoveEvent(event)) return;
+	if (m_event_interface)
+		if(m_event_interface->mouseMoveEvent(event))
+		{
+			if(!m_event_interface->isRunning())
+			{
+				delete m_event_interface; m_event_interface = nullptr;
+			}
+			return;
+		}
 
 	QGraphicsScene::mouseMoveEvent(event);
 }
@@ -215,7 +239,15 @@
  */
 void Diagram::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
 {
-	if (m_event_interface && m_event_interface->mouseReleaseEvent(event)) return;
+	if (m_event_interface)
+		if(m_event_interface->mouseReleaseEvent(event))
+		{
+			if(!m_event_interface->isRunning())
+			{
+				delete m_event_interface; m_event_interface = nullptr;
+			}
+			return;
+		}
 
 	QGraphicsScene::mouseReleaseEvent(event);
 }
@@ -227,7 +259,15 @@
  */
 void Diagram::wheelEvent(QGraphicsSceneWheelEvent *event)
 {
-	if (m_event_interface && m_event_interface->wheelEvent(event)) return;
+	if (m_event_interface)
+		if(m_event_interface->wheelEvent(event))
+		{
+			if(!m_event_interface->isRunning())
+			{
+				delete m_event_interface; m_event_interface = nullptr;
+			}
+			return;
+		}
 
 	QGraphicsScene::wheelEvent(event);
 }
@@ -240,7 +280,15 @@
  */
 void Diagram::keyPressEvent(QKeyEvent *e)
 {
-	if (m_event_interface && m_event_interface->keyPressEvent(e)) return;
+	if (m_event_interface)
+		if(m_event_interface->keyPressEvent(e))
+		{
+			if(!m_event_interface->isRunning())
+			{
+				delete m_event_interface; m_event_interface = nullptr;
+			}
+			return;
+		}
 
 	bool transmit_event = true;
 	if (!isReadOnly()) {
@@ -290,8 +338,16 @@
  */
 void Diagram::keyReleaseEvent(QKeyEvent *e)
 {
-	if (m_event_interface && m_event_interface->KeyReleaseEvent(e)) return;
-
+	if (m_event_interface)
+		if(m_event_interface->keyReleaseEvent(e))
+		{
+			if(!m_event_interface->isRunning())
+			{
+				delete m_event_interface; m_event_interface = nullptr;
+			}
+			return;
+		}
+	
 	bool transmit_event = true;
 	if (!isReadOnly()) {
 		// detecte le relachement d'une touche de direction ( = deplacement d'elements)
@@ -328,7 +384,6 @@
 		event_interface -> init();
 	}
 	m_event_interface = event_interface;
-	connect (m_event_interface, &DiagramEventInterface::finish, this, [this]() { delete this->m_event_interface; this->m_event_interface = nullptr;}, Qt::QueuedConnection);
 }
 
 /**

Modified: trunk/sources/diagramevent/diagrameventinterface.cpp
===================================================================
--- trunk/sources/diagramevent/diagrameventinterface.cpp	2017-05-07 18:54:40 UTC (rev 4958)
+++ trunk/sources/diagramevent/diagrameventinterface.cpp	2017-05-13 16:01:47 UTC (rev 4959)
@@ -72,7 +72,7 @@
 	return false;
 }
 
-bool DiagramEventInterface::KeyReleaseEvent(QKeyEvent *event) {
+bool DiagramEventInterface::keyReleaseEvent(QKeyEvent *event) {
 	Q_UNUSED (event);
 	return false;
 }

Modified: trunk/sources/diagramevent/diagrameventinterface.h
===================================================================
--- trunk/sources/diagramevent/diagrameventinterface.h	2017-05-07 18:54:40 UTC (rev 4958)
+++ trunk/sources/diagramevent/diagrameventinterface.h	2017-05-13 16:01:47 UTC (rev 4959)
@@ -58,7 +58,7 @@
 		virtual bool mouseReleaseEvent     (QGraphicsSceneMouseEvent *event);
 		virtual bool wheelEvent            (QGraphicsSceneWheelEvent *event);
 		virtual bool keyPressEvent         (QKeyEvent *event);
-		virtual bool KeyReleaseEvent       (QKeyEvent *event);
+		virtual bool keyReleaseEvent       (QKeyEvent *event);
 		virtual bool isRunning () const;
 		virtual void init();
 


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