diff --git a/android/jni/com/mapswithme/maps/Framework.cpp b/android/jni/com/mapswithme/maps/Framework.cpp index f829ed19b4..61f5f3663a 100644 --- a/android/jni/com/mapswithme/maps/Framework.cpp +++ b/android/jni/com/mapswithme/maps/Framework.cpp @@ -130,8 +130,7 @@ bool Framework::CreateDrapeEngine(JNIEnv * env, jobject jSurface, int densityDpi m_work.CreateDrapeEngine(make_ref(m_contextFactory), move(p)); m_work.EnterForeground(); - // Load initial state of the map and execute drape tasks which set up custom state. - LoadState(); + // Execute drape tasks which set up custom state. { lock_guard lock(m_drapeQueueMutex); if (!m_drapeTasksQueue.empty()) @@ -143,7 +142,6 @@ bool Framework::CreateDrapeEngine(JNIEnv * env, jobject jSurface, int densityDpi void Framework::DeleteDrapeEngine() { - SaveState(); m_work.EnterBackground(); m_work.DestroyDrapeEngine(); @@ -309,16 +307,6 @@ bool Framework::Search(search::SearchParams const & params) return m_work.Search(params); } -void Framework::LoadState() -{ - m_work.LoadState(); -} - -void Framework::SaveState() -{ - m_work.SaveState(); -} - void Framework::AddLocalMaps() { m_work.RegisterAllMaps(); diff --git a/android/jni/com/mapswithme/maps/Framework.hpp b/android/jni/com/mapswithme/maps/Framework.hpp index 701b1f60d8..b75796d8d5 100644 --- a/android/jni/com/mapswithme/maps/Framework.hpp +++ b/android/jni/com/mapswithme/maps/Framework.hpp @@ -112,9 +112,6 @@ namespace android string GetLastSearchQuery() { return m_searchQuery; } void ClearLastSearchQuery() { m_searchQuery.clear(); } - void LoadState(); - void SaveState(); - void AddLocalMaps(); void RemoveLocalMaps(); diff --git a/android/jni/com/mapswithme/maps/bookmarks/data/BookmarkManager.cpp b/android/jni/com/mapswithme/maps/bookmarks/data/BookmarkManager.cpp index cec06388a2..473fe78fed 100644 --- a/android/jni/com/mapswithme/maps/bookmarks/data/BookmarkManager.cpp +++ b/android/jni/com/mapswithme/maps/bookmarks/data/BookmarkManager.cpp @@ -22,7 +22,6 @@ Java_com_mapswithme_maps_bookmarks_data_BookmarkManager_nativeShowBookmarkOnMap( g_framework->PostDrapeTask([bnc]() { frm()->ShowBookmark(bnc); - frm()->SaveState(); }); } diff --git a/iphone/Maps/Classes/EAGLView.mm b/iphone/Maps/Classes/EAGLView.mm index 3bb2c92f75..42c9cff78a 100644 --- a/iphone/Maps/Classes/EAGLView.mm +++ b/iphone/Maps/Classes/EAGLView.mm @@ -137,7 +137,6 @@ double getExactDPI(double contentScaleFactor) if (GetFramework().GetDrapeEngine() == nullptr) { [self createDrapeEngineWithWidth:w height:h]; - GetFramework().LoadState(); return; } diff --git a/iphone/Maps/Classes/MapViewController.mm b/iphone/Maps/Classes/MapViewController.mm index 952b2ea22b..f3d3470d31 100644 --- a/iphone/Maps/Classes/MapViewController.mm +++ b/iphone/Maps/Classes/MapViewController.mm @@ -374,17 +374,13 @@ NSString * const kAuthorizationSegue = @"Map2AuthorizationSegue"; - (void)onTerminate { - GetFramework().SaveState(); [(EAGLView *)self.view deallocateNative]; } - (void)onEnterBackground { // Save state and notify about entering background. - - Framework & f = GetFramework(); - f.SaveState(); - f.EnterBackground(); + GetFramework().EnterBackground(); } - (void)setMapStyle:(MapStyle)mapStyle diff --git a/map/framework.cpp b/map/framework.cpp index 2ee69f7fbf..ae6be03ed8 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -726,7 +726,7 @@ void Framework::PrepareToShutdown() DestroyDrapeEngine(); } -void Framework::SaveState() +void Framework::SaveViewport() { m2::AnyRectD rect; if (m_currentModelView.isPerspective()) @@ -742,7 +742,7 @@ void Framework::SaveState() Settings::Set("ScreenClipRect", rect); } -void Framework::LoadState() +void Framework::LoadViewport() { m2::AnyRectD rect; if (Settings::Get("ScreenClipRect", rect) && df::GetWorldRect().IsRectInside(rect.GetGlobalRect())) @@ -1048,6 +1048,7 @@ void Framework::MemoryWarning() void Framework::EnterBackground() { SetRenderingEnabled(false); + SaveViewport(); ms::LatLon const ll = MercatorBounds::ToLatLon(GetViewportCenter()); alohalytics::Stats::Instance().LogEvent("Framework::EnterBackground", {{"zoom", strings::to_string(GetDrawScale())}, @@ -1472,6 +1473,8 @@ void Framework::CreateDrapeEngine(ref_ptr contextFactory, if (m_connectToGpsTrack) GpsTracker::Instance().Connect(bind(&Framework::OnUpdateGpsTrackPointsCallback, this, _1, _2)); + LoadViewport(); + // In case of the engine reinitialization simulate the last tap to show selection mark. SimulateLastTapEventIfNeeded(); } diff --git a/map/framework.hpp b/map/framework.hpp index 1a35fae676..39382cf4f4 100644 --- a/map/framework.hpp +++ b/map/framework.hpp @@ -329,7 +329,13 @@ public: void DestroyDrapeEngine(); /// Called when graphics engine should be temporarily paused and then resumed. void SetRenderingEnabled(bool enable); +private: + /// Depends on initialized Drape engine. + void SaveViewport(); + /// Depends on initialized Drape engine. + void LoadViewport(); +public: void ConnectToGpsTracker(); void DisconnectFromGpsTracker(); @@ -423,9 +429,6 @@ public: inline m2::PointD GtoP(m2::PointD const & p) const { return m_currentModelView.GtoP(p); } inline m2::PointD GtoP3d(m2::PointD const & p) const { return m_currentModelView.PtoP3d(m_currentModelView.GtoP(p)); } - void SaveState(); - void LoadState(); - /// Show all model by it's world rect. void ShowAll(); diff --git a/qt/draw_widget.cpp b/qt/draw_widget.cpp index e6641e7a11..cfb77e7b44 100644 --- a/qt/draw_widget.cpp +++ b/qt/draw_widget.cpp @@ -105,6 +105,7 @@ DrawWidget::DrawWidget(QWidget * parent) DrawWidget::~DrawWidget() { + m_framework->EnterBackground(); m_framework.reset(); } @@ -126,17 +127,6 @@ void DrawWidget::UpdateAfterSettingsChanged() m_framework->EnterForeground(); } -void DrawWidget::LoadState() -{ - m_framework->LoadState(); - m_framework->LoadBookmarks(); -} - -void DrawWidget::SaveState() -{ - m_framework->SaveState(); -} - void DrawWidget::ScalePlus() { m_framework->Scale(Framework::SCALE_MAG, true); @@ -210,7 +200,9 @@ void DrawWidget::initializeGL() emit BeforeEngineCreation(); CreateEngine(); - LoadState(); + + m_framework->LoadBookmarks(); + m_framework->EnterForeground(); } void DrawWidget::paintGL() diff --git a/qt/draw_widget.hpp b/qt/draw_widget.hpp index 05b1cb0578..55183bbcc6 100644 --- a/qt/draw_widget.hpp +++ b/qt/draw_widget.hpp @@ -54,9 +54,6 @@ namespace qt void OnLocationUpdate(location::GpsInfo const & info); - void SaveState(); - void LoadState(); - void UpdateAfterSettingsChanged(); void PrepareShutdown(); diff --git a/qt/mainwindow.cpp b/qt/mainwindow.cpp index 6393a70f79..2b4e234e9a 100644 --- a/qt/mainwindow.cpp +++ b/qt/mainwindow.cpp @@ -119,7 +119,8 @@ MainWindow::MainWindow() : m_locationService(CreateDesktopLocationService(*this) } #endif - LoadState(); + // Always show on full screen. + showMaximized(); #ifndef NO_DOWNLOADER // Show intro dialog if necessary @@ -177,27 +178,6 @@ bool MainWindow::winEvent(MSG * msg, long * result) } #endif -MainWindow::~MainWindow() -{ - SaveState(); -} - -void MainWindow::SaveState() -{ - pair xAndY(x(), y()); - pair widthAndHeight(width(), height()); - Settings::Set("MainWindowXY", xAndY); - Settings::Set("MainWindowSize", widthAndHeight); - - m_pDrawWidget->SaveState(); -} - -void MainWindow::LoadState() -{ - // do always show on full screen - showMaximized(); -} - void MainWindow::LocationStateModeChanged(location::EMyPositionMode mode) { if (mode == location::MODE_PENDING_POSITION) diff --git a/qt/mainwindow.hpp b/qt/mainwindow.hpp index 73d01ff74a..146ceba0e0 100644 --- a/qt/mainwindow.hpp +++ b/qt/mainwindow.hpp @@ -34,15 +34,12 @@ namespace qt public: MainWindow(); - virtual ~MainWindow(); virtual void OnLocationError(location::TLocationError errorCode); virtual void OnLocationUpdated(location::GpsInfo const & info); protected: string GetIniFile(); - void SaveState(); - void LoadState(); void LocationStateModeChanged(location::EMyPositionMode mode);