diff options
author | Joaquim Rocha <jrocha@igalia.com> | 2011-01-10 18:33:07 +0100 |
---|---|---|
committer | Armin Berres <armin.berres@basyskom.de> | 2011-01-20 10:04:53 +0100 |
commit | 95d2c1410216f5bb1c690508367fa3b781c549c2 (patch) | |
tree | c2e2bb804524c7c142598f4c316867119a097694 /src | |
parent | fb56abb143616105032ac7f33d0bcfdff8e8dd24 (diff) |
Fixes: NB#198724 - currentStyle() takes noticeable amount of time in application startup
RevBy: Miguel Gomez, Armin Berres
Details:
Use a pointer to keep track of the current window and avoid checking if the
list of windows is empty and getting its first item every time the active
window is to be returned.
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/core/mcomponentdata.cpp | 24 | ||||
-rw-r--r-- | src/corelib/core/mcomponentdata_p.h | 1 | ||||
-rw-r--r-- | src/corelib/style/mstyle.cpp | 4 |
3 files changed, 21 insertions, 8 deletions
diff --git a/src/corelib/core/mcomponentdata.cpp b/src/corelib/core/mcomponentdata.cpp index efc6a5cf..092522f3 100644 --- a/src/corelib/core/mcomponentdata.cpp +++ b/src/corelib/core/mcomponentdata.cpp @@ -203,6 +203,7 @@ MComponentDataPrivate::MComponentDataPrivate() theme(0), deviceProfile(0), windows(), + firstWindow(0), feedbackPlayer(0), locale(), appName(), @@ -1097,10 +1098,7 @@ MWindow *MComponentData::activeWindow() qFatal("MComponentData::activeWindow() - MComponentData instance not yet created."); } - if (gMComponentDataPrivate->windows.isEmpty()) - return 0; - - return gMComponentDataPrivate->windows.at(0); + return gMComponentDataPrivate->firstWindow; } MApplicationWindow *MComponentData::activeApplicationWindow() @@ -1136,8 +1134,10 @@ void MComponentData::setActiveWindow(MWindow *w) if (oldIndex == -1) mWarning("MComponentData::setActiveWindow()") << "attempting to activate unregistered window"; - else + else { gMComponentDataPrivate->windows.move(oldIndex, 0); + gMComponentDataPrivate->firstWindow = w; + } } void MComponentData::registerWindow(MWindow *w) @@ -1145,7 +1145,11 @@ void MComponentData::registerWindow(MWindow *w) if (!gMComponentDataPrivate) { qFatal("MComponentData::registerWindow() - MComponentData instance not yet created."); } - if (!gMComponentDataPrivate->windows.contains(w)) { + if (gMComponentDataPrivate->windows.isEmpty()) { + gMComponentDataPrivate->windows.append(w); + gMComponentDataPrivate->firstWindow = w; + } + else if (!gMComponentDataPrivate->windows.contains(w)) { gMComponentDataPrivate->windows.append(w); } } @@ -1156,6 +1160,14 @@ void MComponentData::unregisterWindow(MWindow *w) qFatal("MComponentData::unregisterWindow() - MComponentData instance not yet created."); } gMComponentDataPrivate->windows.removeAll(w); + if (gMComponentDataPrivate->firstWindow == w) { + if (gMComponentDataPrivate->windows.isEmpty()) { + gMComponentDataPrivate->firstWindow = 0; + } + else { + gMComponentDataPrivate->firstWindow = gMComponentDataPrivate->windows.at(0); + } + } } MFeedbackPlayer *MComponentData::feedbackPlayer() diff --git a/src/corelib/core/mcomponentdata_p.h b/src/corelib/core/mcomponentdata_p.h index 8cc2045c..4de40a73 100644 --- a/src/corelib/core/mcomponentdata_p.h +++ b/src/corelib/core/mcomponentdata_p.h @@ -69,6 +69,7 @@ public: MTheme *theme; MDeviceProfile *deviceProfile; QList<MWindow *> windows; + MWindow *firstWindow; MFeedbackPlayer *feedbackPlayer; MLocale locale; QString appName; diff --git a/src/corelib/style/mstyle.cpp b/src/corelib/style/mstyle.cpp index 3948a487..70763e0b 100644 --- a/src/corelib/style/mstyle.cpp +++ b/src/corelib/style/mstyle.cpp @@ -22,7 +22,7 @@ #include "mstyle_p.h" #include "mtheme.h" #include "mtheme_p.h" -#include "mapplication.h" +#include "mcomponentdata.h" #include "mapplicationwindow.h" // TODO: get rid of this include, make MStyle not to use mgen @@ -200,7 +200,7 @@ const MStyle *MStyleContainer::currentStyle() const { M::Orientation orientation = M::Landscape; - const MWindow *activeWindow = MApplication::activeWindow(); + const MWindow *activeWindow = MComponentData::activeWindow(); if (activeWindow) orientation = activeWindow->orientation(); |