From 2809822c951ac8c835fea5e218c6fe1a8126f3eb Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sun, 14 Oct 2012 20:59:18 +0200 Subject: Fix opening when there are no pinned tabs --- src/application.cpp | 4 ++-- src/sessionmanager.cpp | 21 +++++++++++++++++++-- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/application.cpp b/src/application.cpp index 4f6f9651..1ac66188 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -146,8 +146,8 @@ int Application::newInstance() { restoreOk = SessionManager::self()->restoreJustThePinnedTabs(); } - - isFirstLoad = restoreOk; + + isFirstLoad = !restoreOk; } // first argument: 99% of the time we have just that... diff --git a/src/sessionmanager.cpp b/src/sessionmanager.cpp index 7e13388e..58e9f19e 100644 --- a/src/sessionmanager.cpp +++ b/src/sessionmanager.cpp @@ -82,7 +82,7 @@ int loadTabs(TabWindow *tw, QDomElement & window, bool useFirstTab, bool justThe { QDomElement tab = window.elementsByTagName("tab").at(tabNo).toElement(); bool tabIsPinned = tab.hasAttribute("pinned"); - kDebug() << "Tab # " << tabNo << " is pinned? " << tabIsPinned; + kDebug() << "Tab #" << tabNo << " is pinned? " << tabIsPinned; if (!justThePinnedOnes || tabIsPinned) { @@ -118,6 +118,20 @@ int loadTabs(TabWindow *tw, QDomElement & window, bool useFirstTab, bool justThe } +bool areTherePinnedTabs(QDomElement & window) +{ + bool b = false; + + for (unsigned int tabNo = 0; tabNo < window.elementsByTagName("tab").length(); tabNo++) + { + QDomElement tab = window.elementsByTagName("tab").at(tabNo).toElement(); + b = tab.hasAttribute("pinned"); + } + + return b; +} + + // ------------------------------------------------------------------------------------------------- @@ -256,9 +270,12 @@ bool SessionManager::restoreJustThePinnedTabs() bool done = false; for (unsigned int winNo = 0; winNo < document.elementsByTagName("window").length(); winNo++) { - done = true; QDomElement window = document.elementsByTagName("window").at(winNo).toElement(); + if (!areTherePinnedTabs(window)) + continue; + + done = true; TabWindow *tw = rApp->newTabWindow(); int currentTab = loadTabs(tw, window, true, true); -- cgit v1.2.1