Skip to content
Browse files

Disconnect on application exit

  • Loading branch information...
1 parent 6d6c280 commit f3725df06da8d2fcc40469dd95c76e27a8ea0791 @torarnv committed Feb 29, 2012
Showing with 11 additions and 1 deletion.
  1. +3 −0 src/cometd.cpp
  2. +8 −1 src/cometd.qml
View
3 src/cometd.cpp
@@ -44,6 +44,7 @@
#include "cometdplugin.h"
#include "timerwindow.h"
+#include <QApplication>
#include <QDeclarativeEngine>
#include <QDeclarativeComponent>
#include <QDeclarativeContext>
@@ -62,6 +63,8 @@ Cometd::Cometd(QObject *parent)
// Allow the implementation to pass back the forward-function
cometdContext->setContextProperty("binding", m_binding);
+ cometdContext->setContextProperty("application", qApp);
+
QDeclarativeComponent component(engine, QUrl("qrc:/cometd.qml"));
QObject *implementation = component.create(cometdContext);
cometdContext->setParent(implementation);
View
9 src/cometd.qml
@@ -42,9 +42,16 @@ import QtQuick 1.1
import "cometd.js" as CometdJS
-QtObject {
+Item {
function initialize() {
CometdJS.initialize(timerWindow);
binding.setForwardFunction(CometdJS.forward)
}
+
+ Connections {
+ target: application
+ onAboutToQuit: {
+ CometdJS.forward("disconnect")
+ }
+ }
}

0 comments on commit f3725df

Please sign in to comment.
Something went wrong with that request. Please try again.