Skip to content

Commit

Permalink
Re #8909. Moved drop processing outside the event handler
Browse files Browse the repository at this point in the history
  • Loading branch information
mantid-roman committed Jul 1, 2014
1 parent fb5bc9a commit 1f49ab7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Code/Mantid/MantidPlot/src/TiledWindow.cpp
Expand Up @@ -240,6 +240,7 @@ TiledWindow::TiledWindow(QWidget* parent,
Qt::WFlags f)
: MdiSubWindow(parent, label, name, f),m_scrollArea(NULL),m_layout(NULL),m_buttonPressed(false)
{
connect(this,SIGNAL(dropAtPositionQueued(MdiSubWindow*,QPoint,bool)),this,SLOT(dropAtPosition(MdiSubWindow*,QPoint,bool)),Qt::QueuedConnection);
init(nrows,ncols);
setGeometry(0,0,500,400);
setAcceptDrops( true );
Expand Down Expand Up @@ -1253,7 +1254,8 @@ void TiledWindow::dropEvent(QDropEvent* ev)
if ( ev->source() == static_cast<QWidget*>(this) ) return;
const char *ptr = mimeData->data("TiledWindow").constData();
MdiSubWindow *w = reinterpret_cast<MdiSubWindow*>( const_cast<char*>(ptr) );
dropAtPosition( w, ev->pos(), false );
// Indirect call to dropAtPosition(). Direct call may cause a crash.
emit dropAtPositionQueued( w, ev->pos(), false );
}
else if( mimeData->objectName() == "TiledWindow" && ev->source() == static_cast<QWidget*>(this) )
{
Expand All @@ -1266,7 +1268,7 @@ void TiledWindow::dropEvent(QDropEvent* ev)
// TODO: make it work for multiple selection
auto w = removeTile( m_selection[0] );
clearSelection();
dropAtPosition( w, ev->pos(), false );
emit dropAtPositionQueued( w, ev->pos(), false );
}
else
{
Expand Down
6 changes: 6 additions & 0 deletions Code/Mantid/MantidPlot/src/TiledWindow.h
Expand Up @@ -145,6 +145,12 @@ private slots:
/// Remove (but don't delete) a widget.
void removeWidget(MdiSubWindow *w);

signals:

/// To be sent from the drop event handler in order to call dropAtPosition()
/// indirectly via queued connection
void dropAtPositionQueued(MdiSubWindow *w, QPoint pos, bool global);

private:

/// The inner widget providing scrolling functionality.
Expand Down

0 comments on commit 1f49ab7

Please sign in to comment.