@@ -3297,15 +3297,11 @@ void QgisApp::fileOpen()
3297
3297
3298
3298
try
3299
3299
{
3300
- if ( QgsProject::instance ()->read () )
3300
+ if ( ! QgsProject::instance ()->read () )
3301
3301
{
3302
- setTitleBarText_ ( *this );
3303
- emit projectRead (); // let plug-ins know that we've read in a new
3304
- // project so that they can check any project
3305
- // specific plug-in state
3306
-
3307
- // add this to the list of recently used project files
3308
- saveRecentProjectPath ( fullPath, settings );
3302
+ mMapCanvas ->freeze ( false );
3303
+ mMapCanvas ->refresh ();
3304
+ return ;
3309
3305
}
3310
3306
}
3311
3307
catch ( QgsProjectBadLayerException & e )
@@ -3318,15 +3314,29 @@ void QgisApp::fileOpen()
3318
3314
// attempt to find the new locations for missing layers
3319
3315
// XXX vector file hard-coded -- but what if it's raster?
3320
3316
findLayers_ ( mVectorFileFilter , e.layers () );
3317
+
3318
+ // Tell the legend to update the ordering
3319
+ mMapLegend ->readProject ( e.document () );
3321
3320
}
3322
3321
catch ( std::exception & e )
3323
3322
{
3324
3323
QMessageBox::critical ( this ,
3325
3324
tr ( " QGIS Project Read Error" ),
3326
3325
QString::fromLocal8Bit ( e.what () ) );
3327
3326
QgsDebugMsg ( " BAD QgsMapLayer::LayerType FOUND" );
3327
+ mMapCanvas ->freeze ( false );
3328
+ mMapCanvas ->refresh ();
3329
+ return ;
3328
3330
}
3329
3331
3332
+ setTitleBarText_ ( *this );
3333
+ emit projectRead (); // let plug-ins know that we've read in a new
3334
+ // project so that they can check any project
3335
+ // specific plug-in state
3336
+
3337
+ // add this to the list of recently used project files
3338
+ saveRecentProjectPath ( fullPath, settings );
3339
+
3330
3340
mMapCanvas ->freeze ( false );
3331
3341
mMapCanvas ->refresh ();
3332
3342
}
@@ -3353,33 +3363,14 @@ bool QgisApp::addProject( QString projectFile )
3353
3363
3354
3364
try
3355
3365
{
3356
- if ( QgsProject::instance ()->read ( projectFile ) )
3357
- {
3358
- setTitleBarText_ ( *this );
3359
- int myRedInt = QgsProject::instance ()->readNumEntry ( " Gui" , " /CanvasColorRedPart" , 255 );
3360
- int myGreenInt = QgsProject::instance ()->readNumEntry ( " Gui" , " /CanvasColorGreenPart" , 255 );
3361
- int myBlueInt = QgsProject::instance ()->readNumEntry ( " Gui" , " /CanvasColorBluePart" , 255 );
3362
- QColor myColor = QColor ( myRedInt, myGreenInt, myBlueInt );
3363
- mMapCanvas ->setCanvasColor ( myColor ); // this is fill colour before rendering starts
3364
- QgsDebugMsg ( " Canvas background color restored..." );
3365
-
3366
- mMapCanvas ->updateScale ();
3367
- QgsDebugMsg ( " Scale restored..." );
3368
-
3369
- emit projectRead (); // let plug-ins know that we've read in a new
3370
- // project so that they can check any project
3371
- // specific plug-in state
3372
-
3373
- // add this to the list of recently used project files
3374
- QSettings settings;
3375
- saveRecentProjectPath ( projectFile, settings );
3376
- }
3377
- else
3366
+ if ( ! QgsProject::instance ()->read ( projectFile ) )
3378
3367
{
3379
3368
mMapCanvas ->freeze ( false );
3380
3369
mMapCanvas ->refresh ();
3381
3370
return false ;
3382
3371
}
3372
+ // Continue after last catch statement
3373
+
3383
3374
}
3384
3375
catch ( QgsProjectBadLayerException & e )
3385
3376
{
@@ -3394,8 +3385,16 @@ bool QgisApp::addProject( QString projectFile )
3394
3385
3395
3386
// attempt to find the new locations for missing layers
3396
3387
// XXX vector file hard-coded -- but what if it's raster?
3388
+ QApplication::restoreOverrideCursor ();
3389
+
3397
3390
findLayers_ ( mVectorFileFilter , e.layers () );
3391
+
3392
+ QApplication::setOverrideCursor ( Qt::WaitCursor );
3393
+
3394
+ // Tell the legend to update the ordering
3395
+ mMapLegend ->readProject ( e.document () );
3398
3396
}
3397
+ // Continue after last catch statement
3399
3398
3400
3399
}
3401
3400
catch ( std::exception & e )
@@ -3406,11 +3405,34 @@ bool QgisApp::addProject( QString projectFile )
3406
3405
tr ( " Unable to open project" ),
3407
3406
QString::fromLocal8Bit ( e.what () ) );
3408
3407
3408
+ QApplication::restoreOverrideCursor ();
3409
+
3409
3410
mMapCanvas ->freeze ( false );
3410
3411
mMapCanvas ->refresh ();
3411
3412
return false ;
3412
3413
}
3413
3414
3415
+ // Continue, now with layers found (hopefully)
3416
+
3417
+ setTitleBarText_ ( *this );
3418
+ int myRedInt = QgsProject::instance ()->readNumEntry ( " Gui" , " /CanvasColorRedPart" , 255 );
3419
+ int myGreenInt = QgsProject::instance ()->readNumEntry ( " Gui" , " /CanvasColorGreenPart" , 255 );
3420
+ int myBlueInt = QgsProject::instance ()->readNumEntry ( " Gui" , " /CanvasColorBluePart" , 255 );
3421
+ QColor myColor = QColor ( myRedInt, myGreenInt, myBlueInt );
3422
+ mMapCanvas ->setCanvasColor ( myColor ); // this is fill colour before rendering starts
3423
+ QgsDebugMsg ( " Canvas background color restored..." );
3424
+
3425
+ mMapCanvas ->updateScale ();
3426
+ QgsDebugMsg ( " Scale restored..." );
3427
+
3428
+ emit projectRead (); // let plug-ins know that we've read in a new
3429
+ // project so that they can check any project
3430
+ // specific plug-in state
3431
+
3432
+ // add this to the list of recently used project files
3433
+ QSettings settings;
3434
+ saveRecentProjectPath ( projectFile, settings );
3435
+
3414
3436
QApplication::restoreOverrideCursor ();
3415
3437
3416
3438
mMapCanvas ->freeze ( false );
0 commit comments