Commit 8fafdad5 authored by Samoilenko Yuri's avatar Samoilenko Yuri

some little crash fixes

parent 19740588
......@@ -43,11 +43,11 @@ void sighandler(int signum)
}
}
void initializeTermHandlers(QCoreApplication* app)
void initializeTermHandlers(QCoreApplication* app, Daemon* daemon)
{
::socketpair(AF_UNIX, SOCK_STREAM, 0, sigtermfd);
QSocketNotifier* snTerm = new QSocketNotifier(sigtermfd[1], QSocketNotifier::Read, app);
QObject::connect(snTerm, SIGNAL(activated(int)), app, SLOT(quit()));
QObject::connect(snTerm, SIGNAL(activated(int)), daemon, SLOT(deleteLater()));
action.sa_handler = sighandler;
sigemptyset(&action.sa_mask);
......@@ -73,8 +73,13 @@ int main(int argc, char* argv[])
KApplication app(true); // WARNING GUI required for QClipboard access
app.disableSessionManagement();
initializeTermHandlers(&app);
new Daemon(&app);
//Force daemon to destroy when KApplications in alive
//belongs to bug KApplications resoure freeing
Daemon* daemon = new Daemon(0);
QObject::connect(daemon, SIGNAL(destroyed(QObject*)), &app, SLOT(quit()));
initializeTermHandlers(&app, daemon);
return app.exec();
}
......
......@@ -77,7 +77,8 @@ PluginData PluginLoader::instantiatePluginForDevice(const QString& name, Device*
QVariant deviceVariant = QVariant::fromValue<Device*>(device);
ret.plugin = (KdeConnectPlugin*) factory->create<QObject>(device, QVariantList() << deviceVariant);
//FIXME any reason to use QObject in template param instead KdeConnectPlugin?
ret.plugin = factory->create<KdeConnectPlugin>(device, QVariantList() << deviceVariant);
if (!ret.plugin) {
kDebug(kdeconnect_kded()) << "Error loading plugin";
return ret;
......
......@@ -44,13 +44,10 @@ static const QSet<QString> fields_c = QSet<QString>() << "ip" << "port" << "user
struct SftpPlugin::Pimpl
{
Pimpl()
{
//Add KIO entry to Dolphin's Places
placesModel = new KFilePlacesModel();
}
Pimpl() {}
KFilePlacesModel* placesModel;
//Add KIO entry to Dolphin's Places
KFilePlacesModel placesModel;
QPointer<Mounter> mounter;
};
......@@ -74,17 +71,17 @@ void SftpPlugin::addToDolphin()
{
removeFromDolphin();
KUrl kioUrl("kdeconnect://"+device()->id()+"/");
m_d->placesModel->addPlace(device()->name(), kioUrl, "kdeconnect");
m_d->placesModel.addPlace(device()->name(), kioUrl, "kdeconnect");
kDebug(kdeconnect_kded()) << "add to dolphin";
}
void SftpPlugin::removeFromDolphin()
{
KUrl kioUrl("kdeconnect://"+device()->id()+"/");
QModelIndex index = m_d->placesModel->closestItem(kioUrl);
QModelIndex index = m_d->placesModel.closestItem(kioUrl);
while (index.row() != -1) {
m_d->placesModel->removePlace(index);
index = m_d->placesModel->closestItem(kioUrl);
m_d->placesModel.removePlace(index);
index = m_d->placesModel.closestItem(kioUrl);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment