From 6560459418bf878719086878bc12024efe2b8951 Mon Sep 17 00:00:00 2001 From: nowrep Date: Tue, 3 Apr 2012 19:28:12 +0200 Subject: [PATCH] Fixed loading plugins when using USE_LIBPATH define - reverted displaying page url with QWebFrame::baseUrl() --- src/lib/navigation/navigationbar.cpp | 1 + src/lib/other/pagescreen.cpp | 1 + src/lib/other/statusbarmessage.cpp | 1 + src/lib/plugins/plugins.cpp | 2 +- src/lib/popupwindow/popupstatusbarmessage.cpp | 1 + src/lib/rss/rsswidget.cpp | 1 + src/lib/sidebar/sidebar.cpp | 2 +- src/lib/sidebar/sidebarinterface.h | 2 +- src/lib/webview/siteinfo.cpp | 4 ++-- src/lib/webview/siteinfowidget.cpp | 2 +- src/lib/webview/webpage.cpp | 18 +++++++++++------- src/lib/webview/webpage.h | 2 +- src/lib/webview/webview.cpp | 17 ++++++++++++----- src/lib/webview/webview.h | 4 ++++ src/plugins.pri | 1 + .../AccessKeysNavigation.pro | 1 - .../AccessKeysNavigation/akn_handler.cpp | 1 + src/plugins/MouseGestures/MouseGestures.pro | 1 - src/plugins/TestPlugin/TestPlugin.pro | 1 - src/plugins/TestPlugin/testplugin_sidebar.cpp | 2 +- src/plugins/TestPlugin/testplugin_sidebar.h | 2 +- 21 files changed, 43 insertions(+), 24 deletions(-) diff --git a/src/lib/navigation/navigationbar.cpp b/src/lib/navigation/navigationbar.cpp index 05ddc0764..38e7b829b 100644 --- a/src/lib/navigation/navigationbar.cpp +++ b/src/lib/navigation/navigationbar.cpp @@ -26,6 +26,7 @@ #include "enhancedmenu.h" #include "tabwidget.h" #include "tabbedwebview.h" +#include "webpage.h" #include #include diff --git a/src/lib/other/pagescreen.cpp b/src/lib/other/pagescreen.cpp index 59c33a70c..f28621bf5 100644 --- a/src/lib/other/pagescreen.cpp +++ b/src/lib/other/pagescreen.cpp @@ -18,6 +18,7 @@ #include "pagescreen.h" #include "ui_pagescreen.h" #include "tabbedwebview.h" +#include "webpage.h" #include "globalfunctions.h" #include diff --git a/src/lib/other/statusbarmessage.cpp b/src/lib/other/statusbarmessage.cpp index 307fdc230..549a64336 100644 --- a/src/lib/other/statusbarmessage.cpp +++ b/src/lib/other/statusbarmessage.cpp @@ -19,6 +19,7 @@ #include "qupzilla.h" #include "tabwidget.h" #include "tabbedwebview.h" +#include "webpage.h" #include "squeezelabelv1.h" #include "mainapplication.h" diff --git a/src/lib/plugins/plugins.cpp b/src/lib/plugins/plugins.cpp index b45793ef3..179450b95 100644 --- a/src/lib/plugins/plugins.cpp +++ b/src/lib/plugins/plugins.cpp @@ -160,7 +160,7 @@ void Plugins::loadAvailablePlugins() dirs << mApp->DATADIR + "plugins/" #ifdef Q_WS_X11 #ifdef USE_LIBPATH - << USE_LIBPATH + << USE_LIBPATH + "qupzilla/" #else << "/usr/lib/qupzilla/" #endif diff --git a/src/lib/popupwindow/popupstatusbarmessage.cpp b/src/lib/popupwindow/popupstatusbarmessage.cpp index 346d49aeb..8141c35d1 100644 --- a/src/lib/popupwindow/popupstatusbarmessage.cpp +++ b/src/lib/popupwindow/popupstatusbarmessage.cpp @@ -18,6 +18,7 @@ #include "popupstatusbarmessage.h" #include "popupwindow.h" #include "popupwebview.h" +#include "webpage.h" #include "statusbarmessage.h" #include "mainapplication.h" diff --git a/src/lib/rss/rsswidget.cpp b/src/lib/rss/rsswidget.cpp index f49387d3a..5bfd8733f 100644 --- a/src/lib/rss/rsswidget.cpp +++ b/src/lib/rss/rsswidget.cpp @@ -19,6 +19,7 @@ #include "ui_rsswidget.h" #include "mainapplication.h" #include "tabbedwebview.h" +#include "webpage.h" #include "rssmanager.h" #include "rssnotification.h" diff --git a/src/lib/sidebar/sidebar.cpp b/src/lib/sidebar/sidebar.cpp index 404f707ad..1417ae03a 100644 --- a/src/lib/sidebar/sidebar.cpp +++ b/src/lib/sidebar/sidebar.cpp @@ -134,7 +134,7 @@ void SideBarManager::refreshMenu() continue; } - QAction* act = sidebar.data()->menuAction(); + QAction* act = sidebar.data()->createMenuAction(); act->setData(m_sidebars.key(sidebar)); connect(act, SIGNAL(triggered()), this, SLOT(slotShowSideBar())); diff --git a/src/lib/sidebar/sidebarinterface.h b/src/lib/sidebar/sidebarinterface.h index a77532e2a..4723d5381 100644 --- a/src/lib/sidebar/sidebarinterface.h +++ b/src/lib/sidebar/sidebarinterface.h @@ -32,8 +32,8 @@ public: explicit SideBarInterface(QObject* parent = 0) : QObject(parent) { } virtual QString title() const = 0; - virtual QAction* menuAction() = 0; + virtual QAction* createMenuAction() = 0; virtual QWidget* createSideBarWidget(QupZilla* mainWindow) = 0; }; diff --git a/src/lib/webview/siteinfo.cpp b/src/lib/webview/siteinfo.cpp index facc7bea5..9b7fd9509 100644 --- a/src/lib/webview/siteinfo.cpp +++ b/src/lib/webview/siteinfo.cpp @@ -59,7 +59,7 @@ SiteInfo::SiteInfo(WebView* view, QWidget* parent) ui->listWidget->item(3)->setIcon(QIcon::fromTheme("dialog-password", QIcon(":/icons/preferences/dialog-password.png"))); ui->listWidget->item(0)->setSelected(true); - WebPage* webPage = qobject_cast(view->page()); + WebPage* webPage = view->page(); QWebFrame* frame = view->page()->mainFrame(); QString title = view->title(); QSslCertificate cert = webPage->sslCertificate(); @@ -67,7 +67,7 @@ SiteInfo::SiteInfo(WebView* view, QWidget* parent) //GENERAL ui->heading->setText(QString("%1:").arg(title)); - ui->siteAddress->setText(frame->baseUrl().toString()); + ui->siteAddress->setText(view->url().toString()); ui->sizeLabel->setText(DownloadItem::fileSizeToString(webPage->totalBytes())); QString encoding; diff --git a/src/lib/webview/siteinfowidget.cpp b/src/lib/webview/siteinfowidget.cpp index 89ddc90f6..dfd9244e0 100644 --- a/src/lib/webview/siteinfowidget.cpp +++ b/src/lib/webview/siteinfowidget.cpp @@ -33,7 +33,7 @@ SiteInfoWidget::SiteInfoWidget(QupZilla* mainClass, QWidget* parent) ui->setupUi(this); WebView* view = p_QupZilla->weView(); - WebPage* webPage = qobject_cast(view->page()); + WebPage* webPage = view->page(); QUrl url = view->url(); if (webPage->sslCertificate().isValid()) { diff --git a/src/lib/webview/webpage.cpp b/src/lib/webview/webpage.cpp index 3b639df66..c5eda2a81 100644 --- a/src/lib/webview/webpage.cpp +++ b/src/lib/webview/webpage.cpp @@ -56,7 +56,7 @@ QString WebPage::m_lastUploadLocation = QDir::homePath(); QString WebPage::m_userAgent; QString WebPage::m_fakeUserAgent = "Mozilla/5.0 (" + qz_buildSystem() + ") AppleWebKit/" + qWebKitVersion() + " (KHTML, like Gecko) Chrome/10.0 Safari/" + qWebKitVersion(); QUrl WebPage::m_lastUnsupportedUrl; -QList WebPage::m_deletedPages; +QList WebPage::m_livingPages; WebPage::WebPage(QupZilla* mainClass) : QWebPage() @@ -90,6 +90,8 @@ WebPage::WebPage(QupZilla* mainClass) #ifdef USE_QTWEBKIT_2_2 connect(this, SIGNAL(featurePermissionRequested(QWebFrame*, QWebPage::Feature)), this, SLOT(featurePermissionRequested(QWebFrame*, QWebPage::Feature))); #endif + + m_livingPages.append(this); } QUrl WebPage::url() const @@ -759,9 +761,13 @@ QString WebPage::chooseFile(QWebFrame* originatingFrame, const QString &oldFile) return fileName; } -bool WebPage::isPointerSafeToUse(WebPage *page) +bool WebPage::isPointerSafeToUse(WebPage* page) { - return page == 0 ? false : !m_deletedPages.contains(page); + // Pointer to WebPage is passed with every QNetworkRequest casted to void* + // So there is no way to test whether pointer is still valid or not, except + // this hack. + + return page == 0 ? false : m_livingPages.contains(page); } void WebPage::disconnectObjects() @@ -771,7 +777,7 @@ void WebPage::disconnectObjects() m_runningLoop = 0; } - m_deletedPages.append(this); + m_livingPages.removeOne(this); disconnect(this); m_networkProxy->disconnectObjects(); @@ -786,7 +792,5 @@ WebPage::~WebPage() m_runningLoop = 0; } - if (!m_deletedPages.contains(this)) { - m_deletedPages.append(this); - } + m_livingPages.removeOne(this); } diff --git a/src/lib/webview/webpage.h b/src/lib/webview/webpage.h index 5cf6de012..274a8124c 100644 --- a/src/lib/webview/webpage.h +++ b/src/lib/webview/webpage.h @@ -109,7 +109,7 @@ private: static QString m_userAgent; static QString m_fakeUserAgent; static QUrl m_lastUnsupportedUrl; - static QList m_deletedPages; + static QList m_livingPages; QupZilla* p_QupZilla; NetworkManagerProxy* m_networkProxy; diff --git a/src/lib/webview/webview.cpp b/src/lib/webview/webview.cpp index 725fa9537..301503785 100644 --- a/src/lib/webview/webview.cpp +++ b/src/lib/webview/webview.cpp @@ -49,6 +49,7 @@ WebView::WebView(QWidget* parent) , m_isLoading(false) , m_progress(0) , m_clickedFrame(0) + , m_page(0) , m_actionReload(0) , m_actionStop(0) , m_actionsInitialized(false) @@ -98,7 +99,7 @@ QString WebView::title() const QUrl WebView::url() const { - QUrl returnUrl = page()->mainFrame()->baseUrl(); + QUrl returnUrl = page()->url(); if (returnUrl.isEmpty()) { returnUrl = m_aboutToLoadUrl; @@ -107,14 +108,20 @@ QUrl WebView::url() const return returnUrl; } +WebPage* WebView::page() const +{ + return m_page; +} + void WebView::setPage(QWebPage* page) { QWebView::setPage(page); + m_page = qobject_cast(page); setZoom(WebViewSettings::defaultZoom); connect(page, SIGNAL(saveFrameStateRequested(QWebFrame*, QWebHistoryItem*)), this, SLOT(frameStateChanged())); - mApp->plugins()->emitWebPageCreated(qobject_cast(page)); + mApp->plugins()->emitWebPageCreated(m_page); } void WebView::load(const QUrl &url) @@ -318,7 +325,7 @@ void WebView::slotLoadFinished() mApp->history()->addHistoryEntry(this); } - mApp->autoFill()->completePage(qobject_cast(page())); + mApp->autoFill()->completePage(page()); m_lastUrl = url(); } @@ -377,7 +384,7 @@ void WebView::downloadPage() } DownloadManager* dManager = mApp->downManager(); - dManager->download(request, qobject_cast(page()), false, suggestedFileName); + dManager->download(request, page(), false, suggestedFileName); } void WebView::downloadUrlToDisk() @@ -386,7 +393,7 @@ void WebView::downloadUrlToDisk() QNetworkRequest request(action->data().toUrl()); DownloadManager* dManager = mApp->downManager(); - dManager->download(request, qobject_cast(page()), false); + dManager->download(request, page(), false); } } diff --git a/src/lib/webview/webview.h b/src/lib/webview/webview.h index 0e469805a..7326331e1 100644 --- a/src/lib/webview/webview.h +++ b/src/lib/webview/webview.h @@ -24,6 +24,8 @@ #include "qz_namespace.h" +class WebPage; + class QT_QUPZILLA_EXPORT WebView : public QWebView { Q_OBJECT @@ -34,6 +36,7 @@ public: QString title() const; QUrl url() const; + WebPage* page() const; void setPage(QWebPage* page); void load(const QNetworkRequest &request, QNetworkAccessManager::Operation operation = QNetworkAccessManager::GetOperation, const QByteArray &body = QByteArray()); @@ -152,6 +155,7 @@ private: QWebFrame* m_clickedFrame; QUrl m_clickedUrl; + WebPage* m_page; QAction* m_actionReload; QAction* m_actionStop; bool m_actionsInitialized; diff --git a/src/plugins.pri b/src/plugins.pri index 68f28eed8..27050a2e7 100644 --- a/src/plugins.pri +++ b/src/plugins.pri @@ -26,6 +26,7 @@ INCLUDEPATH += $$PWD/lib/3rdparty\ TEMPLATE = lib CONFIG += plugin +QT *= webkit network DESTDIR = $$PWD/../bin/plugins/ OBJECTS_DIR = build diff --git a/src/plugins/AccessKeysNavigation/AccessKeysNavigation.pro b/src/plugins/AccessKeysNavigation/AccessKeysNavigation.pro index 746294bdf..5b4ab4192 100644 --- a/src/plugins/AccessKeysNavigation/AccessKeysNavigation.pro +++ b/src/plugins/AccessKeysNavigation/AccessKeysNavigation.pro @@ -1,4 +1,3 @@ -QT += webkit TARGET = AccessKeysNavigation os2: TARGET = AcKeyNav diff --git a/src/plugins/AccessKeysNavigation/akn_handler.cpp b/src/plugins/AccessKeysNavigation/akn_handler.cpp index 92c05f363..b54ec1d23 100644 --- a/src/plugins/AccessKeysNavigation/akn_handler.cpp +++ b/src/plugins/AccessKeysNavigation/akn_handler.cpp @@ -35,6 +35,7 @@ */ #include "akn_handler.h" #include "webview.h" +#include "webpage.h" #include #include diff --git a/src/plugins/MouseGestures/MouseGestures.pro b/src/plugins/MouseGestures/MouseGestures.pro index 33d5c002e..4e26f3dc6 100644 --- a/src/plugins/MouseGestures/MouseGestures.pro +++ b/src/plugins/MouseGestures/MouseGestures.pro @@ -1,4 +1,3 @@ -QT += webkit TARGET = MouseGestures os2: TARGET = MouseGes diff --git a/src/plugins/TestPlugin/TestPlugin.pro b/src/plugins/TestPlugin/TestPlugin.pro index f332787ef..2014c78f9 100644 --- a/src/plugins/TestPlugin/TestPlugin.pro +++ b/src/plugins/TestPlugin/TestPlugin.pro @@ -3,7 +3,6 @@ # Project created by QtCreator 2011-02-13T10:23:13 # #------------------------------------------------- -QT += webkit TARGET = TestPlugin # OS/2 allows only 8 chars in TARGET os2: TARGET = TestPlug diff --git a/src/plugins/TestPlugin/testplugin_sidebar.cpp b/src/plugins/TestPlugin/testplugin_sidebar.cpp index b19d9eb10..865ac68e8 100644 --- a/src/plugins/TestPlugin/testplugin_sidebar.cpp +++ b/src/plugins/TestPlugin/testplugin_sidebar.cpp @@ -32,7 +32,7 @@ QString TestPlugin_Sidebar::title() const return tr("Testing Sidebar"); } -QAction* TestPlugin_Sidebar::menuAction() +QAction* TestPlugin_Sidebar::createMenuAction() { QAction* act = new QAction(tr("Testing Sidebar"), 0); act->setCheckable(true); diff --git a/src/plugins/TestPlugin/testplugin_sidebar.h b/src/plugins/TestPlugin/testplugin_sidebar.h index 69faed971..3081e5975 100644 --- a/src/plugins/TestPlugin/testplugin_sidebar.h +++ b/src/plugins/TestPlugin/testplugin_sidebar.h @@ -27,7 +27,7 @@ public: explicit TestPlugin_Sidebar(QObject* parent = 0); QString title() const; - QAction* menuAction(); + QAction* createMenuAction(); QWidget* createSideBarWidget(QupZilla* mainWindow); };