Solved QDBusConnection: systerm Dbus connection created before QCoreApplication
-
Hi @aha_1980 as you said I just declared objects just before usage ,this error is gone . I also tried defining these objects in the header file of class ,there is no error.
Edit: now there is no such warning/error but this code is not giving me status of wifi connection.I mean it should update status every 5 sec, but it just shows status of wifi in the very first iteration.
I have a doubt I don't know If I can ask in the same thread, I have defined various variables,strings,structures in global.h file as external and I call them in different files. will this crash my application ? -
@Anny Your
while(true)
loop is blocking Qt event loop. Remove it and use the asynchronous nature of Qt (you can use QTimer firing in 5 seconds intervals).
-
@jsulm yeah i tried using timer but it not working i dont know why. I m using Timer in other classes , there it works fine. So i switched to thread::sleep
-
@jsulm What I did is, I removed while(true) and sleep command and added timer
connect(&check_network_timer,QTimer::timeout,this,&server_conneciton::run)
check_network_timer.start(5000);
This gives me nothing, app crashes after starting timer -
@Anny
Hi
Where does it crash ?
You can use the debugger to see what is going on.
Using timer normally do not crash so there must be some error in the code. -
@mrjj I tried debugging it using debugger but it gives error box of segmentation fault saying signal received. what does it mean ?
-
@Anny
Hi
It sounds like its crashing. ( segmentation faults = bad pointers, memory issues etc)
Place break point at top of function that timer calls etc and see if it stops. -
@mrjj I added break points it does not stop. But when I run this class as QThread, app didnt crash but stuck after starting timer. I used moveToThread method to run it as thread. I also checked debugger and added some breakpoints, still not stopping and giving same segmentation fault. There is something I am missing out,I dont know what
-
Hi
Do you start it with debug and not just normal run ?
It should stop. -
@mrjj yeah i did it using debug mode. But I got this working now, there was some QThread related issue. Thank you so much everyone