maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   General (https://talk.maemo.org/forumdisplay.php?f=7)
-   -   Trouble with my qt app's .desktop file (https://talk.maemo.org/showthread.php?t=69387)

antman8969 2011-02-05 08:19

Trouble with my qt app's .desktop file
 
So I made a weather application that pulls weather from the National Weather Service using Qt and managed to package it as a deb using scratchbox and install it on the device.

The problem I have now is, I can run it from the command line by executing /usr/bin/weather, but it doesn't seem to work from the .desktop file UNLESS I run it as sudo.

weather.desktop:
Code:

[Desktop Entry]
Encoding=UTF-8
Version=0.1
Type=Application
Name=weather
GenericName=weather
Name[ru]=weather
Exec=sudo run-standalone.sh weather
Icon=weather
X-Window-Icon=weather
Terminal=false
X-Osso-Type=application/x-executable
X-HildonDesktop-ShowInToolbar=true

The weird thing is, the application DOES work without sudo, but only up to the point that I make a network request (using QNetworkAccessManager) then it crashes. If I enter an incorrect zip code into my app (to prompt an error dialog) it works fine...

Any idea why this is?
Did I leave out any important information?


EDIT: Also, I can compile the project and install it on my x86 emulator target in scratchbox and it works fine from the .desktop file...

helihyv 2011-02-05 09:21

Re: Trouble with my qt app's .desktop file
 
Don't know if this is causing your problem, but you should not have the "run-standalone.sh" in the Exec row. It's used in scratchbox only.
Hope this helps..

antman8969 2011-02-05 19:08

Re: Trouble with my qt app's .desktop file
 
Well I tried that but it didn't fix the problem with needing sudo. I actually do need to use it in the exec line if I'm using sudo or the app shows up looking very weird.

I've tried most combinations too, some of which include

Exec=/usr/bin/weather
Exec=sudo /usr/bin/weather
Exec=sudo weather
Exec=weather
Exec=run-standalone.sh weather

and none of them work.... no idea where to even look for help

attila77 2011-02-05 19:46

Re: Trouble with my qt app's .desktop file
 
Quote:

Originally Posted by antman8969 (Post 936951)
Exec=sudo /usr/bin/weather

That's the correct one, but you have to have a proper weather.sudoers in /etc/sudoers.d

That said, I have two remarks

1. I'll leave some very nasty comments on the package page and thumb down if I see someone sudo-ing things just because it's too hard to debug a crash :)

2. Optify

antman8969 2011-02-05 21:13

Re: Trouble with my qt app's .desktop file
 
Quote:

Originally Posted by attila77 (Post 936985)
That's the correct one, but you have to have a proper weather.sudoers in /etc/sudoers.d

That said, I have two remarks

1. I'll leave some very nasty comments on the package page and thumb down if I see someone sudo-ing things just because it's too hard to debug a crash :)

2. Optify

lol this is actually my first time packaging anything for Maemo, let alone Debian. Is adding the proper solution to edit /etc/sudoers.d?
Do other qt applications need to do this aswell?

attila77 2011-02-06 08:46

Re: Trouble with my qt app's .desktop file
 
The proper solution is to set the target to maemo, the build to debug and press the debug button and get a nice stack trace which tells you where's that dangling pointer you missed :) I'm pretty sure you're not using anything that really requires sudo - it's just a coincidence that on your machine with sudo it fails in a way that makes it survive. Applications in general (regardless if they are Qt or not) do not need to put into sudo unless they really deal with system stuff.

antman8969 2011-02-21 02:11

Re: Trouble with my qt app's .desktop file
 
Quote:

Originally Posted by attila77 (Post 937260)
The proper solution is to set the target to maemo, the build to debug and press the debug button and get a nice stack trace which tells you where's that dangling pointer you missed :) I'm pretty sure you're not using anything that really requires sudo - it's just a coincidence that on your machine with sudo it fails in a way that makes it survive. Applications in general (regardless if they are Qt or not) do not need to put into sudo unless they really deal with system stuff.

hmm... Do you think you could tell me why you think there is a dangling pointer in my application? And more importantly, why would running it as sudo ever fix that problem?

Is it relevant that it compiles and runs flawlessly on desktop without sudo aswell?

antman8969 2011-02-21 05:19

Re: Trouble with my qt app's .desktop file
 
UPDATE: I've narrowed the code down to one line that breaks it...


Code:


setWindowTitle(location.toElement().text());
ui->title->setText(weekList.at(0).toElement().attribute("period-name"));
    for(int i = 0; i < 12; i++){
        QString title(weekList.at(i).toElement().attribute("period-name"));
        QString condition(conditionList.at(i).toElement().attribute("weather-summary"));
    QString temp(hiloList.at(i));
        QString icon(iconList.at(i).toElement().text());
        dayPeriods->at(i)->setInfo(title, condition, temp, icon);
}


The hilo list is constructed here :

Code:

/*merge temps into one day period ordered list*/
QList<QString> hiloList;
if(hiList.size() > lowList.size()){
    for(int i = 0; i < lowList.size(); i++){
        hiloList.append(QString("Hi: " + hiList.at(i).toElement().text()) + " F");
        hiloList.append(QString("Lo: " + lowList.at(i).toElement().text()) + " F");
    }
    hiloList.append(QString("Hi: " + hiList.at(lowList.size()).toElement().text()) + " F");
   
}else{
    for(int i = 0; i < hiList.size(); i++){
        hiloList.append(QString("Lo: " + lowList.at(i).toElement().text()) + " F");
        hiloList.append(QString("Hi: " + hiList.at(i).toElement().text()) + " F");
    }
    hiloList.append(QString("Lo: " + lowList.at(hiList.size()).toElement().text()) + " F");
}

If I comment out the hilo list, the app no longer crashes... but the UI isn't updated at all....
This is such a weird problem and I've got no idea where to look. There are no dangling pointers...

The worst part is, it works fine if I compile and install in the x86 target emulator in scratchbox...

Remember, it DOES work if I execute
Code:

/usr/bin/weather
from the command line, just not in a .desktop file....

attila77 2011-02-22 23:34

Re: Trouble with my qt app's .desktop file
 
Is there any chance that your index is out of bounds ? Also, try to run it in debug mode on-device, you might catch an ASSERT or similar.

antman8969 2011-02-22 23:39

Re: Trouble with my qt app's .desktop file
 
Quote:

Originally Posted by attila77 (Post 953184)
Is there any chance that your index is out of bounds ? Also, try to run it in debug mode on-device, you might catch an ASSERT or similar.

Was solved in another thread actually, I just don't see a way to mark this a "solved" or something similar lol

But yea, there was an index out of bounds, but that was a symptom of the real problem. I was creating a temporary file "tmp.xml" in the current working directory, which apparently you don't have permission for when starting the app with a .desktop file. So I changed it to /tmp/tmp.xml and it worked fine!

Thanks to nicolai in this thread:
http://talk.maemo.org/showthread.php?t=70158&page=2


All times are GMT. The time now is 12:17.

vBulletin® Version 3.8.8