Skip to content

Commit 46fedf9

Browse files
committed
Only refresh canvas when needed on drop event
1 parent e7ea582 commit 46fedf9

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

src/app/qgisapp.cpp

+21-8
Original file line numberDiff line numberDiff line change
@@ -804,6 +804,7 @@ void QgisApp::dragEnterEvent( QDragEnterEvent *event )
804804

805805
void QgisApp::dropEvent( QDropEvent *event )
806806
{
807+
mMapCanvas->freeze();
807808
// get the file list
808809
QList<QUrl>::iterator i;
809810
QList<QUrl>urls = event->mimeData()->urls();
@@ -817,6 +818,7 @@ void QgisApp::dropEvent( QDropEvent *event )
817818
openFile( fileName );
818819
}
819820
}
821+
820822
if ( QgsMimeDataUtils::isUriList( event->mimeData() ) )
821823
{
822824
QgsMimeDataUtils::UriList lst = QgsMimeDataUtils::decodeUriList( event->mimeData() );
@@ -832,7 +834,8 @@ void QgisApp::dropEvent( QDropEvent *event )
832834
}
833835
}
834836
}
835-
837+
mMapCanvas->freeze(false);
838+
mMapCanvas->refresh();
836839
event->acceptProposedAction();
837840
}
838841

@@ -2486,6 +2489,7 @@ void QgisApp::addVectorLayer()
24862489

24872490
bool QgisApp::addVectorLayers( QStringList const & theLayerQStringList, const QString& enc, const QString dataSourceType )
24882491
{
2492+
bool wasfrozen = mMapCanvas->isFrozen();
24892493
QList<QgsMapLayer *> myList;
24902494
foreach ( QString src, theLayerQStringList )
24912495
{
@@ -2590,10 +2594,13 @@ bool QgisApp::addVectorLayers( QStringList const & theLayerQStringList, const QS
25902594
// update UI
25912595
qApp->processEvents();
25922596

2593-
// draw the map
2594-
mMapCanvas->freeze( false );
2595-
mMapCanvas->refresh();
2596-
2597+
// Only update the map if we frozen in this method
2598+
// Let the caller do it otherwise
2599+
if ( !wasfrozen )
2600+
{
2601+
mMapCanvas->freeze( false );
2602+
mMapCanvas->refresh();
2603+
}
25972604
// Let render() do its own cursor management
25982605
// QApplication::restoreOverrideCursor();
25992606

@@ -6743,6 +6750,8 @@ QgsVectorLayer* QgisApp::addVectorLayer( QString vectorLayerPath, QString baseNa
67436750
return NULL;
67446751
}
67456752

6753+
bool wasfrozen = mMapCanvas->isFrozen();
6754+
67466755
mMapCanvas->freeze();
67476756

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

6800-
// draw the map
6801-
mMapCanvas->freeze( false );
6802-
mMapCanvas->refresh();
6809+
// Only update the map if we frozen in this method
6810+
// Let the caller do it otherwise
6811+
if ( !wasfrozen )
6812+
{
6813+
mMapCanvas->freeze( false );
6814+
mMapCanvas->refresh();
6815+
}
68036816

68046817
// Let render() do its own cursor management
68056818
// QApplication::restoreOverrideCursor();

0 commit comments

Comments
 (0)