@@ -126,8 +126,10 @@ ModuleProxyWidget::ModuleProxyWidget(ModuleWidget* module, QGraphicsItem* parent
126126 setAcceptDrops (true );
127127
128128 connect (module , SIGNAL (noteUpdated (const Note&)), this , SLOT (updateNote (const Note&)));
129- connect (module , SIGNAL (requestModuleVisible ()), this , SLOT (ensureVisible ()));
129+ connect (module , SIGNAL (requestModuleVisible ()), this , SLOT (ensureThisVisible ()));
130130 connect (module , SIGNAL (deleteMeLater ()), this , SLOT (deleteLater ()));
131+
132+ stackDepth_ = 0 ;
131133}
132134
133135ModuleProxyWidget::~ModuleProxyWidget ()
@@ -139,7 +141,12 @@ void ModuleProxyWidget::createStartupNote()
139141 module_->createStartupNote ();
140142}
141143
142- void ModuleProxyWidget::ensureVisible ()
144+ void ModuleProxyWidget::ensureThisVisible ()
145+ {
146+ ensureItemVisible (this );
147+ }
148+
149+ void ModuleProxyWidget::ensureItemVisible (QGraphicsItem* item)
143150{
144151 auto views = scene ()->views ();
145152 if (!views.isEmpty ())
@@ -149,7 +156,7 @@ void ModuleProxyWidget::ensureVisible()
149156 {
150157 return ; // the call below led to a crash when too zoomed in to fit a module.
151158 }
152- views[0 ]->ensureVisible (this );
159+ views[0 ]->ensureVisible (item );
153160 }
154161}
155162
@@ -211,6 +218,7 @@ static int snapTo(int oldPos)
211218
212219void ModuleProxyWidget::mouseReleaseEvent (QGraphicsSceneMouseEvent *event)
213220{
221+ stackDepth_ = 0 ;
214222 auto taggingOn = data (TagLayerKey).toBool ();
215223 if (taggingOn)
216224 return ;
@@ -246,15 +254,25 @@ void ModuleProxyWidget::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
246254{
247255 if (PortWidget* p = qobject_cast<PortWidget*>(pressedSubWidget_))
248256 {
249- p->doMouseMove (event->buttons (), mapToScene (event->pos ()));
257+ auto conn = p->doMouseMove (event->buttons (), mapToScene (event->pos ()));
258+ if (conn)
259+ {
260+ stackDepth_++;
261+ if (stackDepth_ > 1 )
262+ return ;
263+ ensureItemVisible (conn);
264+ }
265+ stackDepth_ = 0 ;
250266 return ;
251267 }
252268 if (grabbedByWidget_)
253269 {
254270 return ;
255271 }
256- ensureVisible ();
272+ if (stackDepth_ == 0 )
273+ ensureThisVisible ();
257274 QGraphicsItem::mouseMoveEvent (event);
275+ stackDepth_ = 0 ;
258276}
259277
260278bool ModuleProxyWidget::isSubwidget (QWidget* alienWidget) const
0 commit comments