1
mirror of https://invent.kde.org/network/falkon.git synced 2024-11-11 01:22:10 +01:00

Unregister scheme handler / extra js objects by pointer not name

This commit is contained in:
David Rosca 2018-02-11 11:50:05 +01:00
parent 9db6745ee5
commit 3333b61650
No known key found for this signature in database
GPG Key ID: EBC3FC294452C6D8
9 changed files with 16 additions and 12 deletions

View File

@ -236,9 +236,9 @@ void NetworkManager::registerExtensionSchemeHandler(const QString &name, Extensi
m_extensionScheme->registerHandler(name, handler);
}
void NetworkManager::unregisterExtensionSchemeHandler(const QString &name)
void NetworkManager::unregisterExtensionSchemeHandler(ExtensionSchemeHandler *handler)
{
m_extensionScheme->unregisterHandler(name);
m_extensionScheme->unregisterHandler(handler);
}
void NetworkManager::loadSettings()

View File

@ -43,7 +43,7 @@ public:
void removeUrlInterceptor(UrlInterceptor *interceptor);
void registerExtensionSchemeHandler(const QString &name, ExtensionSchemeHandler *handler);
void unregisterExtensionSchemeHandler(const QString &name);
void unregisterExtensionSchemeHandler(ExtensionSchemeHandler *handler);
void loadSettings();
void shutdown();

View File

@ -52,7 +52,7 @@ void ExtensionSchemeManager::registerHandler(const QString &name, ExtensionSchem
m_handlers[name] = handler;
}
void ExtensionSchemeManager::unregisterHandler(const QString &name)
void ExtensionSchemeManager::unregisterHandler(ExtensionSchemeHandler *handler)
{
m_handlers.remove(name);
m_handlers.remove(m_handlers.key(handler));
}

View File

@ -40,7 +40,7 @@ public:
void requestStarted(QWebEngineUrlRequestJob *job) override;
void registerHandler(const QString &name, ExtensionSchemeHandler *handler);
void unregisterHandler(const QString &name);
void unregisterHandler(ExtensionSchemeHandler *handler);
private:
QHash<QString, ExtensionSchemeHandler*> m_handlers;

View File

@ -56,9 +56,9 @@ void ExternalJsObject::registerExtraObject(const QString &id, QObject *object)
}
// static
void ExternalJsObject::unregisterExtraObject(const QString &id)
void ExternalJsObject::unregisterExtraObject(QObject *object)
{
s_extraObjects.remove(id);
s_extraObjects.remove(s_extraObjects.key(object));
}
QObject *ExternalJsObject::speedDial() const

View File

@ -42,7 +42,7 @@ public:
static void setupWebChannel(QWebChannel *webChannel, WebPage *page);
static void registerExtraObject(const QString &id, QObject *object);
static void unregisterExtraObject(const QString &id);
static void unregisterExtraObject(QObject *object);
private:
QObject *speedDial() const;

View File

@ -49,7 +49,7 @@ GM_Manager::GM_Manager(const QString &sPath, QObject* parent)
GM_Manager::~GM_Manager()
{
ExternalJsObject::unregisterExtraObject(QSL("greasemonkey"));
ExternalJsObject::unregisterExtraObject(m_jsObject);
}
void GM_Manager::showSettings(QWidget* parent)

View File

@ -65,8 +65,10 @@ void VerticalTabsPlugin::init(InitState state, const QString &settingsPath)
m_controller = new VerticalTabsController(this);
SideBarManager::addSidebar(QSL("VerticalTabs"), m_controller);
m_schemeHandler = new VerticalTabsSchemeHandler(this);
mApp->networkManager()->registerExtensionSchemeHandler(QSL("verticaltabs"), m_schemeHandler);
mApp->plugins()->registerAppEventHandler(PluginProxy::KeyPressHandler, this);
mApp->networkManager()->registerExtensionSchemeHandler(QSL("verticaltabs"), new VerticalTabsSchemeHandler);
setWebTabBehavior(m_addChildBehavior);
loadStyleSheet(m_theme);
@ -89,7 +91,7 @@ void VerticalTabsPlugin::unload()
delete m_controller;
m_controller = nullptr;
mApp->networkManager()->unregisterExtensionSchemeHandler(QSL("verticaltabs"));
mApp->networkManager()->unregisterExtensionSchemeHandler(m_schemeHandler);
}
bool VerticalTabsPlugin::testPlugin()

View File

@ -22,6 +22,7 @@
class BrowserWindow;
class VerticalTabsController;
class VerticalTabsSchemeHandler;
class VerticalTabsPlugin : public QObject, public PluginInterface
{
@ -76,6 +77,7 @@ private:
QString m_settingsPath;
VerticalTabsController *m_controller = nullptr;
VerticalTabsSchemeHandler *m_schemeHandler = nullptr;
ViewType m_viewType = TabListView;
bool m_replaceTabBar = false;
AddChildBehavior m_addChildBehavior = AppendChild;