Bug 314356 - bluedevil breaks after suspend
Summary: bluedevil breaks after suspend
Status: RESOLVED FIXED
Alias: None
Product: solid
Classification: Unmaintained
Component: bluetooth (show other bugs)
Version: 4.9.5
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: Alex Fiestas
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-02-03 14:41 UTC by Ilya Basin
Modified: 2014-11-15 10:00 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
x (6.73 KB, text/plain)
2013-03-10 17:08 UTC, Ilya Basin
Details
kded4-5.txt (101.12 KB, text/plain)
2013-03-10 18:25 UTC, Ilya Basin
Details
Usa usableAdapter instead of default (1.70 KB, patch)
2013-03-10 19:07 UTC, Alex Fiestas
Details
kded4-9.txt: browse files, suspend, then try browse again (120.51 KB, text/plain)
2013-03-10 19:50 UTC, Ilya Basin
Details
kded4-12.txt: suspend multiple times (163.03 KB, text/plain)
2013-03-11 06:56 UTC, Ilya Basin
Details
Clean the object on unregistered, emit changed on initialize and added some debug (2.65 KB, patch)
2013-03-11 09:33 UTC, Alex Fiestas
Details
kded4-17.txt (193.01 KB, text/plain)
2013-03-11 10:20 UTC, Ilya Basin
Details
kded4-21.txt (83.69 KB, text/plain)
2013-03-11 12:20 UTC, Ilya Basin
Details
output process info (1.13 KB, text/plain)
2013-03-11 14:52 UTC, Alex Fiestas
Details
kded4-25.txt: with the process.txt patch (97.66 KB, text/plain)
2013-03-11 17:29 UTC, Ilya Basin
Details
kded4-29.txt (392.00 KB, text/plain)
2013-03-11 19:47 UTC, Ilya Basin
Details
kded4-30.txt icon vanish again (89.24 KB, text/plain)
2013-03-11 19:54 UTC, Ilya Basin
Details
kded4-32.txt (144.73 KB, text/plain)
2013-03-14 05:26 UTC, Ilya Basin
Details
0001-more-fixes-in-BlueDevilDaemon-monolithic.patch (6.57 KB, patch)
2013-03-15 08:19 UTC, Ilya Basin
Details
0001-BlueDevilDaemon-monolithic-fix-race-condition-use-QD.patch (5.53 KB, patch)
2013-03-15 10:28 UTC, Ilya Basin
Details
kded4-41-QDBusServiceWatcher.txt (3.08 KB, text/plain)
2013-03-15 10:33 UTC, Ilya Basin
Details
kded4-50.txt (1.81 KB, text/plain)
2013-03-17 05:32 UTC, Ilya Basin
Details
kded4-52.txt (29.99 KB, text/plain)
2013-03-19 17:37 UTC, Ilya Basin
Details
adding some debug (1.47 KB, patch)
2013-03-19 22:43 UTC, Alex Fiestas
Details
bluedevil-monolithic-20130321-095003.kcrash (3.36 KB, application/octet-stream)
2013-03-21 05:57 UTC, Ilya Basin
Details
0001-don-t-touch-m_defaultAdapter-on-adapterPoweredChange.patch (5.85 KB, patch)
2013-04-06 08:23 UTC, Ilya Basin
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ilya Basin 2013-02-03 14:41:37 UTC
After I suspend and wake my PC, the bluetooth tray icon vanishes and I'm unable to browse devices/send files over bluetooth.
Programs that use BT directly, like smartcam and obexfs are not affected.

Reproducible: Always




* package version(s)
bluedevil 1.3-1
libbluedevil 1.9.2-1
bluez 4.101-1
KDE 4.9.5-1

$ lsusb
Bus 003 Device 002: ID 0a5c:2121 Broadcom Corp. BCM2210 Bluetooth
Comment 1 Ilya Basin 2013-02-14 09:16:15 UTC
please help
Comment 2 Alex Fiestas 2013-02-21 22:13:44 UTC
does it help restarting bluetooth service?

Can you give me the output of qdbus --system org.bluez  ?

Thanks and sorry for the delay on answering
Comment 3 Ilya Basin 2013-02-23 11:25:49 UTC
> does it help restarting bluetooth service?
Yes

> Can you give me the output of qdbus --system org.bluez ?
$ qdbus --system org.bluez
/
/org
/org/bluez
/org/bluez/404
/org/bluez/404/any
/org/bluez/404/hci0
/org/bluez/404/hci0/dev_A8_7E_33_D7_29_DB
/org/bluez/test
Comment 4 Alex Fiestas 2013-02-24 13:29:44 UTC
In Archlinux I can reproduce this, will investigate and fix.

thanks for the report !
Comment 5 Alex Fiestas 2013-03-08 21:02:57 UTC
Can you reproduce this all the time? I have been trying to reproduce this today and so far no luck.
Comment 6 Ilya Basin 2013-03-09 06:59:43 UTC
Yes.
Comment 7 Alex Fiestas 2013-03-10 16:25:48 UTC
Can you attach the following information?

Go into a termnial and do:
killall -9 kded4; sleep 5; kded4 --nofork > /tmp/kded4.txt

Then wait a few seconds, suspend, resume (to reproduce the problem) and attach the kded4.txt

Thanks !
Comment 8 Ilya Basin 2013-03-10 17:08:14 UTC
Created attachment 77916 [details]
x

actually, it prints to stderr
Comment 9 Alex Fiestas 2013-03-10 17:40:09 UTC
Oh indeed, can you add stderr too please?
Comment 10 Ilya Basin 2013-03-10 17:43:43 UTC
it is stderr ^
Comment 11 Alex Fiestas 2013-03-10 18:08:22 UTC
Oh then, open "debugdialog", enable everything with the word "KDED" on it, and try again.

You are missing a lot of debug info, for example KDED saying "loading module bluedevil".
Comment 12 Ilya Basin 2013-03-10 18:15:05 UTC
What debugdialog ? Don't find this command in $PATH or in Desktop search
Comment 13 Ilya Basin 2013-03-10 18:25:15 UTC
Created attachment 77917 [details]
kded4-5.txt

never mind, found it. See the attached file
Comment 14 Alex Fiestas 2013-03-10 19:07:13 UTC
Created attachment 77921 [details]
Usa usableAdapter instead of default

Sometimes BlueZ won't emit "defaultAdapterChange", it never worked 100% perfect and it has been removed in BlueZ5...

So instead of it use "usableAdapter", which do not relay on BlueZ and should work just fine.
Comment 15 Alex Fiestas 2013-03-10 19:07:48 UTC
Haven't test the patch, but should fix the issue, can you test it please?
Comment 16 Ilya Basin 2013-03-10 19:45:14 UTC
The bluetooth icon now reappears after suspend, but "browse files" doesn't work as before, until I restart the bluetooth service or relogin.
Comment 17 Ilya Basin 2013-03-10 19:50:05 UTC
Created attachment 77922 [details]
kded4-9.txt: browse files, suspend, then try browse again
Comment 18 Alex Fiestas 2013-03-10 21:50:31 UTC
Same patch could be almost applied to browse files, will do some testing and push the patch.
Comment 19 Alex Fiestas 2013-03-10 22:10:44 UTC
Git commit 61e35f00d7f571166ff9a5139a74b510af279c5e by Àlex Fiestas.
Committed on 10/03/2013 at 23:07.
Pushed by afiestas into branch 'master'.

Added missing emit defaultChanged

M  +1    -0    bluedevil/bluedevilmanager.cpp

http://commits.kde.org/libbluedevil/61e35f00d7f571166ff9a5139a74b510af279c5e
Comment 20 Alex Fiestas 2013-03-10 22:11:43 UTC
That should fix this, anyway I will switch to usableAdapter in most of the places.
Comment 21 Alex Fiestas 2013-03-10 22:40:27 UTC
Git commit 52bd6afb50e70171d99f792f70dd4542ac0a056f by Àlex Fiestas.
Committed on 10/03/2013 at 23:36.
Pushed by afiestas into branch 'master'.

Use usableAdapter instead of defaultAdapter

defaultAdapter has been removed from BlueZ5 because it was problematic,
we had our share of problems with it so we implemented usableAdapter
which basically does what defaultAdapter does but additionally checks
isPowered.

M  +2    -2    src/actionplugins/audio/helper/audiohelper.cpp
M  +2    -2    src/actionplugins/input/helper/inputhelper.cpp
M  +2    -2    src/actionplugins/networkdun/helper/networkdunhelper.cpp
M  +2    -2    src/actionplugins/networkpanu/helper/networkpanuhelper.cpp
M  +7    -7    src/actionplugins/sendfile/helper/discoverwidget.cpp
M  +1    -1    src/actionplugins/sendfile/helper/pages/connectingpage.cpp
M  +3    -3    src/actionplugins/sendfile/helper/sendfilewizard.cpp
M  +1    -1    src/daemon/helpers/authorize/authorize.cpp
M  +1    -1    src/daemon/helpers/filereceiver/openobex/serversession.cpp
M  +3    -3    src/daemon/helpers/filereceiver/service.cpp
M  +10   -10   src/daemon/kded/BlueDevilDaemon.cpp
M  +1    -1    src/daemon/kded/BlueDevilDaemon.h
M  +4    -4    src/daemon/kded/bluezagent.cpp
M  +4    -4    src/daemon/obexftpkded/ObexFtpDaemon.cpp
M  +1    -1    src/daemon/obexftpkded/ObexFtpDaemon.h
M  +2    -2    src/fileitemactionplugin/sendfileitemaction.cpp
M  +8    -8    src/kcmodule/bluedeviladapters.cpp
M  +1    -1    src/kcmodule/bluedeviladapters.h
M  +14   -14   src/kcmodule/bluedevildevices.cpp
M  +1    -1    src/kcmodule/bluedevildevices.h
M  +6    -6    src/kcmodule/bluedeviltransfer.cpp
M  +1    -1    src/kcmodule/bluedeviltransfer.h
M  +5    -5    src/kcmodule/systemcheck.cpp
M  +2    -2    src/kio/bluetooth/kiobluetooth.cpp
M  +0    -2    src/kio/bluetooth/kiobluetooth.h
M  +16   -16   src/monolithic/monolithic.cpp
M  +1    -1    src/wizard/bluewizard.cpp
M  +7    -7    src/wizard/pages/discoverpage.cpp
M  +1    -1    src/wizard/pages/fail.cpp
M  +1    -1    src/wizard/pages/keyboardpairing.cpp
M  +1    -1    src/wizard/pages/legacypairing.cpp
M  +1    -1    src/wizard/pages/legacypairingdatabase.cpp
M  +2    -2    src/wizard/pages/nopairing.cpp
M  +1    -1    src/wizard/pages/servicespage.cpp
M  +3    -3    src/wizard/pages/ssppairing.cpp

http://commits.kde.org/bluedevil/52bd6afb50e70171d99f792f70dd4542ac0a056f
Comment 22 Ilya Basin 2013-03-11 06:56:07 UTC
Created attachment 77937 [details]
kded4-12.txt: suspend multiple times

Applied your patches. The icon now vanishes after ~3 suspends. See attached file.
Comment 23 Ilya Basin 2013-03-11 07:37:39 UTC
Same problem with git head
Comment 24 Alex Fiestas 2013-03-11 09:16:43 UTC
Damn it... I can see another problem in your log, I kind of know how to fix it, working on it.
Comment 25 Alex Fiestas 2013-03-11 09:33:22 UTC
Created attachment 77940 [details]
Clean the object on unregistered, emit changed on initialize and added some debug
Comment 26 Alex Fiestas 2013-03-11 09:34:01 UTC
This patch cleans the object and emits defaultChanged and usableChanged when initialize is called again, we where missing both things though the later I suspect is the one causing the problems.

Please, test again and let's see if we fixed it for good this time !
Comment 27 Ilya Basin 2013-03-11 10:20:00 UTC
Created attachment 77945 [details]
kded4-17.txt

Applied your patch to libbluetooth. It didn't help. I don't see the new messages in kded4 output.
See the attached file.
Comment 28 Alex Fiestas 2013-03-11 10:58:02 UTC
Ok, so at least the Daemon seems to be working fine and the double "Added" or "Removed" events we were getting before are gone (the patch works).

Now the problem seems to be only in monolithic (the thing that appears in the systray), you can check in the log "it probably crashed".

Going to try to reproduce and cook a patch.
Comment 29 Alex Fiestas 2013-03-11 11:06:33 UTC
Git commit 8559a0d2436da9792611a6bf9446b8a58fe55917 by Àlex Fiestas.
Committed on 11/03/2013 at 12:03.
Pushed by afiestas into branch 'master'.

Emit defaultAdapterChanged and usableAdapterChanged on initialize

After all this is the first time they change, from 0 to *

M  +3    -0    bluedevil/bluedevilmanager.cpp

http://commits.kde.org/libbluedevil/8559a0d2436da9792611a6bf9446b8a58fe55917
Comment 30 Alex Fiestas 2013-03-11 11:06:33 UTC
Git commit 19792c0085ed11c877e34d268b51c576b80215ef by Àlex Fiestas.
Committed on 11/03/2013 at 12:02.
Pushed by afiestas into branch 'master'.

Properly clean the object when the service is unregistered

M  +21   -17   bluedevil/bluedevilmanager.cpp

http://commits.kde.org/libbluedevil/19792c0085ed11c877e34d268b51c576b80215ef
Comment 31 Ilya Basin 2013-03-11 11:27:45 UTC
should I try yet?
Comment 32 Alex Fiestas 2013-03-11 11:29:55 UTC
Try updating both, bluedevil and libbluedevil.
Comment 33 Ilya Basin 2013-03-11 12:20:14 UTC
Created attachment 77947 [details]
kded4-21.txt

> bluedevilmonolithic(19846): Communication problem with  "bluedevilmonolithic" , it probably crashed. 
It's still there
Comment 34 Alex Fiestas 2013-03-11 14:52:39 UTC
Created attachment 77955 [details]
output process info
Comment 35 Alex Fiestas 2013-03-11 14:53:32 UTC
Same deal, compile (bluedevil this time) with the applied patch, restart kded, reproduce add info.

This time the patch only adds some more debug.

I have an idea of how to fix this, but provide the info just to be sure.
Comment 36 Alex Fiestas 2013-03-11 15:21:20 UTC
Additionally you can try to reproduce this with the branch: betterMonolithicHandling let's se if we are lucky :p
Comment 37 Ilya Basin 2013-03-11 17:29:49 UTC
Created attachment 77960 [details]
kded4-25.txt: with the process.txt patch
Comment 38 Ilya Basin 2013-03-11 17:34:22 UTC
Should kded4 now print anything if I kill bluedevil-monolithic ? Well it doesn't.
Comment 39 Alex Fiestas 2013-03-11 19:12:34 UTC
Ups, forgot to push some debugs, can you try again?

Thanks for all the testing btw.
Comment 40 Ilya Basin 2013-03-11 19:47:47 UTC
Created attachment 77964 [details]
kded4-29.txt

Switched to betterMonolithicHandling.
No problem with the icon after 7 suspends.
Comment 41 Ilya Basin 2013-03-11 19:54:14 UTC
Created attachment 77965 [details]
kded4-30.txt icon vanish again

Nope, the problem's still there
Comment 42 Alex Fiestas 2013-03-11 22:00:12 UTC
Update libbluedevil and try again (314c139e701d5619d8990638202f9593cbe9a6fb).

Thanks for all the feedback.
Comment 43 Ilya Basin 2013-03-14 05:26:23 UTC
Created attachment 78053 [details]
kded4-32.txt
Comment 44 Ilya Basin 2013-03-14 06:08:35 UTC
It could be a bug in or misuse of KUniqueApplication. What do you think?
Comment 45 Ilya Basin 2013-03-14 07:23:07 UTC
Is bluedevil-monolithic supposed to restart on resume?
Comment 46 Ilya Basin 2013-03-14 14:04:45 UTC
> Is bluedevil-monolithic supposed to restart on resume?
OK, I see where it's killed.

Now, although bluedevil-monolithic is started, BlueDevilDaemon::monolithicStarted() is not called. I added kDebug() there and also set breakpoints with gdb.
The flag m_monolithicStarted is never set.
Comment 47 Ilya Basin 2013-03-14 17:53:44 UTC
I'm not a QT fan, but my tests show that:
- the started() and finished(int) events only work with QProcess::start(), not startDetached()
- For in-stack QProcess variables the finished(int) event is called on function return, not when the subprocess really dies
Comment 48 Alex Fiestas 2013-03-15 00:27:00 UTC
Hehe you are completely right, gonna push the change.
Comment 49 Alex Fiestas 2013-03-15 00:56:13 UTC
Git commit af6b207ab400c713d5b33ce3a35d9684f7c98d64 by Àlex Fiestas.
Committed on 15/03/2013 at 01:52.
Pushed by afiestas into branch 'betterMonolithicHandling'.

Proper usage of QProcess if we intend to use the signals

Use QProcess:start instead of detached, also move to QProcess instead
of KProcess since we do not need any of the things provided by the later

M  +9    -6    src/daemon/kded/BlueDevilDaemon.cpp
M  +1    -1    src/daemon/kded/BlueDevilDaemon.h

http://commits.kde.org/bluedevil/af6b207ab400c713d5b33ce3a35d9684f7c98d64
Comment 50 Ilya Basin 2013-03-15 01:50:12 UTC
Because bluedevil-monolithic goes to background, BlueDevilDaemon::finished triggers immediately.

Both BlueDevilDaemon::finished() and BlueDevilDaemon::monolithicQuit() were added in the same commit. monolithicQuit() is triggered on d-bus reply.
I suspect that after processing the "quit" message bluedevil-monolithic is still registered in dbus for some time and will prevent another instance. So this watcher is probably not needed.

If it's true, bluedevil-monolithic needs a flag to run in foreground.
Comment 51 Ilya Basin 2013-03-15 04:07:01 UTC
Wait for my patch
Comment 52 Ilya Basin 2013-03-15 08:19:53 UTC
Created attachment 78090 [details]
0001-more-fixes-in-BlueDevilDaemon-monolithic.patch

This is for branch betterMonolithicHandling.
But don't push it yet: I got an advice to use QDBusServiceWatcher. This way we can wait for the monolithic process launched elsewhere and probably the implementation will be simpler
Comment 53 Alex Fiestas 2013-03-15 09:24:01 UTC
Oks, if not probably next week I will have time to look into this and fix it for once, as you can see in the timestamps I'm doing it late at night before sleep so I'm not putting any thought on it :p

Thanks for all the feedback, really appreciated.
Comment 54 Ilya Basin 2013-03-15 10:28:55 UTC
Created attachment 78093 [details]
0001-BlueDevilDaemon-monolithic-fix-race-condition-use-QD.patch

This patch applies to master. It uses QDBusServiceWatcher to launch monolithik when the service is unregistered. It's simpler than using QProcess signals, I reverted to startDetached().

The new branch called betterMonolithicHandling2. Compare:

$ git diff --stat master betterMonolithicHandling
 src/daemon/kded/BlueDevilDaemon.cpp | 94 
 src/daemon/kded/BlueDevilDaemon.h   |  9 
 2 files changed, 92 insertions(+), 11 deletions(-)
$ git diff --stat master betterMonolithicHandling2
 src/daemon/kded/BlueDevilDaemon.cpp | 64 
 src/daemon/kded/BlueDevilDaemon.h   |  5 
 2 files changed, 58 insertions(+), 11 deletions(-)
Comment 55 Ilya Basin 2013-03-15 10:33:32 UTC
Created attachment 78094 [details]
kded4-41-QDBusServiceWatcher.txt

The "it probably crashed" message is there, but now it's not fatal. We could avoid it with some flag variables, but it would make it complex.
Comment 56 Ilya Basin 2013-03-17 05:32:00 UTC
Created attachment 78124 [details]
kded4-50.txt

Today BlueDevilDaemon didn't return to online mode after suspend, see the attached log.
I guess bluedevilmanager found it not usable
Comment 57 Alex Fiestas 2013-03-17 19:14:05 UTC
Git commit 8d771c35f2b4f0e0f3ee7ebcf156d461a2dd5eb3 by Àlex Fiestas, on behalf of Ilya Basin.
Committed on 15/03/2013 at 10:51.
Pushed by afiestas into branch 'master'.

BlueDevilDaemon/monolithic fix race condition, use QDBusServiceWatcher

M  +53   -11   src/daemon/kded/BlueDevilDaemon.cpp
M  +5    -0    src/daemon/kded/BlueDevilDaemon.h

http://commits.kde.org/bluedevil/8d771c35f2b4f0e0f3ee7ebcf156d461a2dd5eb3
Comment 58 Alex Fiestas 2013-03-17 19:17:28 UTC
Last mode change in the log is to online, can't it be again monolithic not getting executed ?

This week I will have time to deep test this and try to fix it once for all.

Thanks for everything, really appreciated !
Comment 59 Ilya Basin 2013-03-19 17:37:32 UTC
Created attachment 78213 [details]
kded4-52.txt

> can't it be again monolithic not getting executed ?
It's bluedevilmanager.
I added more logging there. Today it happened again.
According to the log, after wake _k_adapterRemoved() was called twice with "/org/bluez/426/hci0", then _k_adapterAdded() was called with the parameter "/org/bluez/426/hci0", then it called findUsableAdapter() and it returned NULL, so the server remained in offline mode.
grep -i "monolith\|bluedevil\|powerdevil" /tmp/kded4-51.txt > /tmp/kded4-52.txt
Comment 60 Ilya Basin 2013-03-19 17:57:44 UTC
m_adaptersHash could not be empty. So the only reason is it wasn't powered.
But plain obex programs work now, so it is powered.
Comment 61 Alex Fiestas 2013-03-19 22:43:48 UTC
Created attachment 78220 [details]
adding some debug
Comment 62 Alex Fiestas 2013-03-19 22:45:49 UTC
The other explanation will be that the service is still detected as offline so Manager::Adapters will  return an empty list.

Add the debug in the last attached patch, if this is confirmed and our logic is correct then we'll have to workaround this in deviceAdded.
Comment 63 Ilya Basin 2013-03-21 05:57:30 UTC
Created attachment 78254 [details]
bluedevil-monolithic-20130321-095003.kcrash

Today monolithic crashed in Monolithic::onlineMode(), because Manager::self()->usableAdapter() returned NULL
Comment 64 Ilya Basin 2013-03-21 06:10:40 UTC
service.patch> "qDebug()"
It's hard to grep for it. Do you know how to workaround the lack of kDebug ? I added this:
    #define myDebug() qDebug() << Q_FUNC_INFO << ": "
but I don't know how to add the process name and pid, like "kded(586) ..."
Comment 65 Ilya Basin 2013-03-21 17:19:18 UTC
I got the proof.
At first _k_adapterAdded() called, only then the property "Powered" is set to true:

void BlueDevil::Manager::Private::_k_adapterAdded(const QDBusObjectPath&) :  Added:  "/org/bluez/412/hci0" 
void BlueDevil::Manager::Private::_k_adapterAdded(const QDBusObjectPath&) :  !m_usableAdapter 
BlueDevil::Adapter* BlueDevil::Manager::Private::findUsableAdapter() :  
BlueDevil::Adapter* BlueDevil::Manager::Private::findUsableAdapter() :  defAdapter =  0x2724110 
void BlueDevil::Adapter::Private::fetchProperties() :  this =  0x2839bf0  m_powered =  false 
BlueDevil::Adapter* BlueDevil::Manager::Private::findUsableAdapter() :  defAdapter->isPowered =  false 
QList<BlueDevil::Adapter*> BlueDevil::Manager::adapters() const :  
QList<BlueDevil::Adapter*> BlueDevil::Manager::adapters() const :  return d->m_adaptersHash.values() 
BlueDevil::Adapter* BlueDevil::Manager::Private::findUsableAdapter() :  adapter =  0x2724110 
BlueDevil::Adapter* BlueDevil::Manager::Private::findUsableAdapter() :  adapter->isPowered() =  false 
BlueDevil::Adapter* BlueDevil::Manager::Private::findUsableAdapter() :  return 0 
void BlueDevil::Manager::Private::_k_adapterAdded(const QDBusObjectPath&) :  m_usableAdapter =  0x0 
void BlueDevil::Manager::Private::_k_adapterAdded(const QDBusObjectPath&) :  m_oldUsableAdapter =  0x0 
void BlueDevil::Adapter::Private::_k_propertyChanged(const QString&, const QDBusVariant&) :  this =  0x2839bf0   "UUIDs"  =  "" 
void BlueDevil::Adapter::Private::_k_propertyChanged(const QString&, const QDBusVariant&) :  this =  0x2839bf0   "Pairable"  =  "true" 
void BlueDevil::Adapter::Private::_k_propertyChanged(const QString&, const QDBusVariant&) :  this =  0x2839bf0   "Powered"  =  "true" 
void BlueDevil::Adapter::Private::_k_propertyChanged(const QString&, const QDBusVariant&) :  this =  0x2839bf0  m_powered =  true 
void BlueDevil::Adapter::Private::_k_propertyChanged(const QString&, const QDBusVariant&) :  this =  0x2839bf0   "Pairable"  =  "true" 
void BlueDevil::Adapter::Private::_k_propertyChanged(const QString&, const QDBusVariant&) :  this =  0x2839bf0   "Discoverable"  =  "true"
Comment 66 Alex Fiestas 2013-03-24 17:17:28 UTC
Git commit 0fa1e2bebe56c0409e8911537da0502b671b6ff2 by Àlex Fiestas.
Committed on 24/03/2013 at 18:12.
Pushed by afiestas into branch 'master'.

On Adapter::poweredChanged, check if we need to modify usableAdapter

One of the things we do in usableAdapter is check if the adapter is
powered, if it is not then we consider the adapter not usable.

It happens that an adaptor is added but it is not powered so we discaard
it as an usableAdapter. When that happens we have to make sure that we
are listening to "poweredChanged" and check if usableAdapter should be
changed when that happens (an adapter has become powered, use it in case
we do not have any usableAdapter).

this whole usableAdapter thing is a mess we have to revise for 2.0

M  +30   -0    bluedevil/bluedevilmanager.cpp
M  +1    -0    bluedevil/bluedevilmanager.h

http://commits.kde.org/libbluedevil/0fa1e2bebe56c0409e8911537da0502b671b6ff2
Comment 67 Alex Fiestas 2013-03-24 17:18:06 UTC
Git commit 014cc0b890a8232f44fc6f231bb01b86cbaafb62 by Àlex Fiestas.
Committed on 24/03/2013 at 17:32.
Pushed by afiestas into branch 'master'.

Check if there is an usable adapter before going to onlineMode

An adapter can be added but it might no be usable (not powered) so we
have to be certain that there is an usableAdapter before going into
onlineMode.

In the future We should connect only to usableAdapterChanged to make
the code waay simpler, but since we are close to release let's not
modify too much code.

M  +1    -1    src/monolithic/monolithic.cpp

http://commits.kde.org/bluedevil/014cc0b890a8232f44fc6f231bb01b86cbaafb62
Comment 68 Ilya Basin 2013-03-28 05:03:50 UTC
I think there's a leak of Adapter objects. I put qDebug into its constructor and destructor and after several suspends the constructor was called 10 times and the destructor only 4 times.
Of course, some objects wasn't destroyed at monolithic termination; it's normal.
But according to logs there was this case inside one monolithic instance:
Adapter 1 is created in Manager::Private::initialize(). It has powered = true
Later is called _k_adapterPoweredChanged(false) and sets m_defaultAdapter = 0
Later findUsableAdapter() calls defaultAdapter() that creates Adapter 2, because m_defaultAdapter == 0; Adapter 1 still exists, but not in the list anymore
_k_adapterRemoved() is called and destroys Adapter 2
Then findUsableAdapter() calls defaultAdapter() that creates Adapter 3
Then _k_adapterAdded() is called and creates Adapter 4
Then Adapter 1 _k_propertyChanged() is called with "Powered"  =  "true"

In the end we have Adapter 4 in the list and Adaper 1 and 3 lost. One question: why set m_defaultAdapter = 0 in _k_adapterPoweredChanged?
Comment 69 Alex Fiestas 2013-04-05 16:42:02 UTC
Git commit 47bc8b9bce111e901aae6aba23a32d9828a4988e by Àlex Fiestas.
Committed on 05/04/2013 at 18:39.
Pushed by afiestas into branch 'master'.

Avoid creating Adapter objects for dbusPath that we already have

M  +6    -1    bluedevil/bluedevilmanager.cpp

http://commits.kde.org/libbluedevil/47bc8b9bce111e901aae6aba23a32d9828a4988e
Comment 70 Alex Fiestas 2013-04-05 16:43:46 UTC
Indeed we were not checking if we already had an adapter for that dbusPath.

is the bug gone with the latest patch (014cc0b890a82) ?
Comment 71 Ilya Basin 2013-04-06 04:48:20 UTC
I think m_bluezManagerInterface->DefaultAdapter() should be used only during init and after that manager should rely only on events. This way after _k_adapterRemoved() the call to Manager::defaultAdapter() will return NULL which is correct.
Comment 72 Ilya Basin 2013-04-06 08:23:14 UTC
Created attachment 78671 [details]
0001-don-t-touch-m_defaultAdapter-on-adapterPoweredChange.patch
Comment 73 Alex Fiestas 2014-01-19 17:09:30 UTC
Sorry for the huge delay replying to the bug :/

Going to check if the patch make sense and if it should be applied in 2.0 branch as well.

Will release new point releases if needed, thanks !
Comment 74 Alex Fiestas 2014-01-20 01:13:23 UTC
Can you check this patch as well?
http://bugsfiles.kde.org/attachment.cgi?id=84736
Comment 75 Ilya Basin 2014-01-26 11:10:58 UTC
Please give me some time to remember. I haven't used that PC for a while.
Comment 76 auxsvr 2014-10-25 07:06:11 UTC
Bluetooth on KDE 4.14.2 is always on after suspend, even though I set it to off beforehand.
Comment 77 David Rosca 2014-11-15 10:00:48 UTC
Git commit 38f78cae2e67562bb40640a87d9f34f8e1a4f200 by David Rosca.
Committed on 15/11/2014 at 09:58.
Pushed by drosca into branch 'master'.

Restore adapter powered state after wakeup from suspend

M  +45   -1    src/daemon/kded/BlueDevilDaemon.cpp
M  +2    -0    src/daemon/kded/BlueDevilDaemon.h

http://commits.kde.org/bluedevil/38f78cae2e67562bb40640a87d9f34f8e1a4f200