summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2013-04-28 17:04:33 +0200
committerAndrea Diamantini <adjam7@gmail.com>2013-04-28 17:04:33 +0200
commit53cd1dfd2d5ee7c464dc7f681616325e63814327 (patch)
tree3a9717f57d71bacd2774ec4a311691764185e3dd
parentAvoid a possible crash if rekonqWindow is not properly detected (diff)
downloadrekonq-53cd1dfd2d5ee7c464dc7f681616325e63814327.tar.xz
Properly register rekonq window to activities
-rw-r--r--src/application.cpp43
-rw-r--r--src/application.h4
-rw-r--r--src/tabwindow/tabwidget.cpp2
3 files changed, 30 insertions, 19 deletions
diff --git a/src/application.cpp b/src/application.cpp
index fd84c44b..cfe4cae4 100644
--- a/src/application.cpp
+++ b/src/application.cpp
@@ -389,7 +389,6 @@ RekonqWindow *Application::rekonqWindow(const QString & activityID)
if (!active)
{
RekonqWindowList wList = m_rekonqWindows;
-
#ifdef HAVE_KACTIVITIES
wList = tabsForActivity(activityID);
#endif
@@ -414,6 +413,7 @@ RekonqWindowList Application::tabsForActivity(const QString & activityID)
QString id = activityID;
if ( id.isEmpty() )
id = m_activityConsumer->currentActivity();
+
return m_activityRekonqWindowsMap[id];
#else
return m_rekonqWindows;
@@ -427,11 +427,31 @@ bool Application::haveWindowsForActivity(const QString & activityID)
}
+// -----------------------------------------------------------------------------------------------------------
+
RekonqWindow *Application::newWindow(bool withTab, bool PrivateBrowsingMode)
{
RekonqWindow *w = new RekonqWindow(withTab, PrivateBrowsingMode);
+ setWindowInfo(w);
+ w->show();
+
+ return w;
+}
+
+
+RekonqWindow *Application::newWindow(WebPage *pg)
+{
+ RekonqWindow *w = new RekonqWindow(pg);
+ setWindowInfo(w);
+ w->show();
+
+ return w;
+}
+
+void Application::setWindowInfo(RekonqWindow *w)
+{
// set object name
int n = m_rekonqWindows.count() + 1;
w->setObjectName(QL1S("win") + QString::number(n));
@@ -444,12 +464,11 @@ RekonqWindow *Application::newWindow(bool withTab, bool PrivateBrowsingMode)
#ifdef HAVE_KACTIVITIES
QString currentActivity = m_activityConsumer->currentActivity();
m_activityRekonqWindowsMap[currentActivity].prepend(w);
-#endif
+#endif
+}
- w->show();
- return w;
-}
+// -----------------------------------------------------------------------------------------------------------
WebTab *Application::newWebApp()
@@ -951,19 +970,7 @@ void Application::pageCreated(WebPage *pg)
{
if (m_rekonqWindows.isEmpty())
{
- // NOTE: This is "adjusted" from newRekonqWindow() code...
- RekonqWindow *w = new RekonqWindow(pg);
-
- // set object name
- int n = m_rekonqWindows.count() + 1;
- w->setObjectName(QL1S("win") + QString::number(n));
-
- // This is used to track which window was activated most recently
- w->installEventFilter(this);
-
- m_rekonqWindows.prepend(w);
- w->show();
-
+ newWindow(pg);
return;
}
diff --git a/src/application.h b/src/application.h
index e9efc0fb..ae248a3e 100644
--- a/src/application.h
+++ b/src/application.h
@@ -120,6 +120,7 @@ public Q_SLOTS:
);
RekonqWindow *newWindow(bool withTab = true, bool PrivateBrowsingMode = false);
+ RekonqWindow *newWindow(WebPage *pg);
WebTab *newWebApp();
@@ -132,6 +133,9 @@ protected:
Q_SIGNALS:
void toggleBookmarksToolbar(bool);
+private:
+ void setWindowInfo(RekonqWindow *);
+
private Q_SLOTS:
void updateConfiguration();
diff --git a/src/tabwindow/tabwidget.cpp b/src/tabwindow/tabwidget.cpp
index 12341759..1b5bca30 100644
--- a/src/tabwindow/tabwidget.cpp
+++ b/src/tabwindow/tabwidget.cpp
@@ -720,7 +720,7 @@ void TabWidget::detachTab(int index, RekonqWindow *toWindow)
RekonqWindow *w = 0;
w = (toWindow == 0)
- ? new RekonqWindow(false)
+ ? rApp->newWindow(false)
: toWindow;
TabWidget *hostTabWidget = w->tabWidget();