Skip to content

Commit

Permalink
Only refresh canvas when needed on drop event
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanW2 committed Jun 6, 2013
1 parent e7ea582 commit 46fedf9
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions src/app/qgisapp.cpp
Expand Up @@ -804,6 +804,7 @@ void QgisApp::dragEnterEvent( QDragEnterEvent *event )

void QgisApp::dropEvent( QDropEvent *event )
{
mMapCanvas->freeze();
// get the file list
QList<QUrl>::iterator i;
QList<QUrl>urls = event->mimeData()->urls();
Expand All @@ -817,6 +818,7 @@ void QgisApp::dropEvent( QDropEvent *event )
openFile( fileName );
}
}

if ( QgsMimeDataUtils::isUriList( event->mimeData() ) )
{
QgsMimeDataUtils::UriList lst = QgsMimeDataUtils::decodeUriList( event->mimeData() );
Expand All @@ -832,7 +834,8 @@ void QgisApp::dropEvent( QDropEvent *event )
}
}
}

mMapCanvas->freeze(false);
mMapCanvas->refresh();
event->acceptProposedAction();
}

Expand Down Expand Up @@ -2486,6 +2489,7 @@ void QgisApp::addVectorLayer()

bool QgisApp::addVectorLayers( QStringList const & theLayerQStringList, const QString& enc, const QString dataSourceType )
{
bool wasfrozen = mMapCanvas->isFrozen();
QList<QgsMapLayer *> myList;
foreach ( QString src, theLayerQStringList )
{
Expand Down Expand Up @@ -2590,10 +2594,13 @@ bool QgisApp::addVectorLayers( QStringList const & theLayerQStringList, const QS
// update UI
qApp->processEvents();

// draw the map
mMapCanvas->freeze( false );
mMapCanvas->refresh();

// Only update the map if we frozen in this method
// Let the caller do it otherwise
if ( !wasfrozen )
{
mMapCanvas->freeze( false );
mMapCanvas->refresh();
}
// Let render() do its own cursor management
// QApplication::restoreOverrideCursor();

Expand Down Expand Up @@ -6743,6 +6750,8 @@ QgsVectorLayer* QgisApp::addVectorLayer( QString vectorLayerPath, QString baseNa
return NULL;
}

bool wasfrozen = mMapCanvas->isFrozen();

mMapCanvas->freeze();

// Let render() do its own cursor management
Expand Down Expand Up @@ -6797,9 +6806,13 @@ QgsVectorLayer* QgisApp::addVectorLayer( QString vectorLayerPath, QString baseNa
// update UI
qApp->processEvents();

// draw the map
mMapCanvas->freeze( false );
mMapCanvas->refresh();
// Only update the map if we frozen in this method
// Let the caller do it otherwise
if ( !wasfrozen )
{
mMapCanvas->freeze( false );
mMapCanvas->refresh();
}

// Let render() do its own cursor management
// QApplication::restoreOverrideCursor();
Expand Down

0 comments on commit 46fedf9

Please sign in to comment.