emailuis/nmailui/src/nmapplication.cpp
changeset 53 bf7eb7911fc5
parent 30 759dc5235cdb
child 47 f83bd4ae1fe3
child 54 997a02608b3a
--- a/emailuis/nmailui/src/nmapplication.cpp	Fri Jun 11 13:27:14 2010 +0300
+++ b/emailuis/nmailui/src/nmapplication.cpp	Wed Jun 23 18:00:21 2010 +0300
@@ -98,7 +98,7 @@
         delete mQueryDialog;
         mQueryDialog=NULL;
     }
-    
+
 #ifndef NM_WINS_ENV
 	delete mSendServiceInterface;
 	delete mSendServiceInterface2;
@@ -123,6 +123,10 @@
     }
     // Effects needs to be deleted before MainWindow.
     delete mEffects;
+    if (mMainWindow) {
+        // workaround: assert failure may happen otherwise
+        mMainWindow->close();
+    }
     delete mMainWindow;
     delete mAttaManager;
     delete mSettingsViewLauncher;
@@ -357,8 +361,10 @@
         // was already in foreground..
         if (mServiceViewId == topViewId) {
             mServiceViewId = NmUiViewNone;
+            NM_COMMENT("Returned from service view");
 
-            // if started as embedded, do not hide the app
+            // if started as embedded or while the app was in foreground,
+            // do not hide the app
             if (!XQServiceUtil::isEmbedded() &&
                 !mForegroundService) {
                 XQServiceUtil::toBackground(true);
@@ -410,6 +416,11 @@
 			// from the stack. Open editors are not closed.
 			// Also if the view is same than the new one, keep it open (reload the content).
 
+
+		    // reset the foreground service flag while popping the views
+		    bool previousForegroundService = mForegroundService;
+		    mForegroundService = true;
+
 		    // at least one view must remain in the stack
 			while (mViewStack->count()>1) {
 			    NmUiViewId topId = mViewStack->top()->nmailViewId();
@@ -423,6 +434,7 @@
 			        break;
 			    }
 			}
+			mForegroundService = previousForegroundService;
         }
 
         // Check whether requested view is already active
@@ -491,12 +503,12 @@
                     resetViewStack();
                     break;
             }
+        }
 
-            if (startParam && startParam->service()) {
-				// Store the view id that was launched as service
-        		mServiceViewId = mActiveViewId;
-			}
-        }
+        if (startParam && startParam->service()) {
+            // Store the view id that was launched as service
+            mServiceViewId = mActiveViewId;
+		}
     }
 }
 
@@ -617,7 +629,7 @@
                 mQueryDialog=NULL;
             }
             mQueryDialog = NmUtilities::displayQuestionNote(hbTrId("txt_mail_dialog_address_or_password_incorrect"),
-                                                    this, SLOT(launchSettings(HbAction*)));                        
+                                                    this, SLOT(launchSettings(HbAction*)));
         }
         if(event.mOperationType == Synch && event.mCompletionCode == NmServerConnectionError) {
             mLastOperationMailbox=event.mMailboxId;
@@ -626,7 +638,7 @@
                 mQueryDialog=NULL;
             }
             mQueryDialog = NmUtilities::displayQuestionNote(hbTrId("txt_mail_dialog_server_settings_incorrect"),
-                                                    this, SLOT(launchSettings(HbAction*)));                
+                                                    this, SLOT(launchSettings(HbAction*)));
         }
         // following applies to all operation/event types
         if(event.mCompletionCode == NmConnectionError) {
@@ -641,14 +653,14 @@
 void NmApplication::launchSettings(HbAction* action)
 {
     NM_FUNCTION;
-    
+
     // Check whether yes button was pressed
     if (mQueryDialog&& action == mQueryDialog->actions().at(0)) {
         // create settingslauncher if doesn't exist
         if(!mSettingsViewLauncher) {
             mSettingsViewLauncher = new NmSettingsViewLauncher();
             }
-    
+
         if(mSettingsViewLauncher) {
             // mailboxname required
             NmMailboxMetaData *mailboxMetaData = mUiEngine->mailboxById(mLastOperationMailbox); // no ownership
@@ -656,8 +668,8 @@
                 // launch
                 mSettingsViewLauncher->launchSettingsView(mLastOperationMailbox, mailboxMetaData->name());
             }
-        }     
-    }    
+        }
+    }
 }
 
 /*!