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

some little crash fixes

parent 19740588
...@@ -43,11 +43,11 @@ void sighandler(int signum) ...@@ -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); ::socketpair(AF_UNIX, SOCK_STREAM, 0, sigtermfd);
QSocketNotifier* snTerm = new QSocketNotifier(sigtermfd[1], QSocketNotifier::Read, app); 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; action.sa_handler = sighandler;
sigemptyset(&action.sa_mask); sigemptyset(&action.sa_mask);
...@@ -73,8 +73,13 @@ int main(int argc, char* argv[]) ...@@ -73,8 +73,13 @@ int main(int argc, char* argv[])
KApplication app(true); // WARNING GUI required for QClipboard access KApplication app(true); // WARNING GUI required for QClipboard access
app.disableSessionManagement(); 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(); return app.exec();
} }
......
...@@ -77,7 +77,8 @@ PluginData PluginLoader::instantiatePluginForDevice(const QString& name, Device* ...@@ -77,7 +77,8 @@ PluginData PluginLoader::instantiatePluginForDevice(const QString& name, Device*
QVariant deviceVariant = QVariant::fromValue<Device*>(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) { if (!ret.plugin) {
kDebug(kdeconnect_kded()) << "Error loading plugin"; kDebug(kdeconnect_kded()) << "Error loading plugin";
return ret; return ret;
......
...@@ -44,13 +44,10 @@ static const QSet<QString> fields_c = QSet<QString>() << "ip" << "port" << "user ...@@ -44,13 +44,10 @@ static const QSet<QString> fields_c = QSet<QString>() << "ip" << "port" << "user
struct SftpPlugin::Pimpl struct SftpPlugin::Pimpl
{ {
Pimpl() Pimpl() {}
{
//Add KIO entry to Dolphin's Places
placesModel = new KFilePlacesModel();
}
KFilePlacesModel* placesModel; //Add KIO entry to Dolphin's Places
KFilePlacesModel placesModel;
QPointer<Mounter> mounter; QPointer<Mounter> mounter;
}; };
...@@ -74,17 +71,17 @@ void SftpPlugin::addToDolphin() ...@@ -74,17 +71,17 @@ void SftpPlugin::addToDolphin()
{ {
removeFromDolphin(); removeFromDolphin();
KUrl kioUrl("kdeconnect://"+device()->id()+"/"); 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"; kDebug(kdeconnect_kded()) << "add to dolphin";
} }
void SftpPlugin::removeFromDolphin() void SftpPlugin::removeFromDolphin()
{ {
KUrl kioUrl("kdeconnect://"+device()->id()+"/"); KUrl kioUrl("kdeconnect://"+device()->id()+"/");
QModelIndex index = m_d->placesModel->closestItem(kioUrl); QModelIndex index = m_d->placesModel.closestItem(kioUrl);
while (index.row() != -1) { while (index.row() != -1) {
m_d->placesModel->removePlace(index); m_d->placesModel.removePlace(index);
index = m_d->placesModel->closestItem(kioUrl); 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