Active Topics

 


Reply
Thread Tools
antman8969's Avatar
Posts: 64 | Thanked: 58 times | Joined on Jul 2010 @ United States
#1
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...

Last edited by antman8969; 2011-02-21 at 05:53.
 
Posts: 63 | Thanked: 139 times | Joined on Apr 2010
#2
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's Avatar
Posts: 64 | Thanked: 58 times | Joined on Jul 2010 @ United States
#3
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
 
Posts: 3,319 | Thanked: 5,610 times | Joined on Aug 2008 @ Finland
#4
Originally Posted by antman8969 View Post
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
__________________
Blogging about mobile linux - The Penguin Moves!
Maintainer of PyQt (see introduction and docs), AppWatch, QuickBrownFox, etc
 
antman8969's Avatar
Posts: 64 | Thanked: 58 times | Joined on Jul 2010 @ United States
#5
Originally Posted by attila77 View Post
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?
 
Posts: 3,319 | Thanked: 5,610 times | Joined on Aug 2008 @ Finland
#6
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.
__________________
Blogging about mobile linux - The Penguin Moves!
Maintainer of PyQt (see introduction and docs), AppWatch, QuickBrownFox, etc
 
antman8969's Avatar
Posts: 64 | Thanked: 58 times | Joined on Jul 2010 @ United States
#7
Originally Posted by attila77 View Post
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's Avatar
Posts: 64 | Thanked: 58 times | Joined on Jul 2010 @ United States
#8
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....

Last edited by antman8969; 2011-02-21 at 05:23.
 
Posts: 3,319 | Thanked: 5,610 times | Joined on Aug 2008 @ Finland
#9
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.
__________________
Blogging about mobile linux - The Penguin Moves!
Maintainer of PyQt (see introduction and docs), AppWatch, QuickBrownFox, etc
 
antman8969's Avatar
Posts: 64 | Thanked: 58 times | Joined on Jul 2010 @ United States
#10
Originally Posted by attila77 View Post
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
 
Reply


 
Forum Jump


All times are GMT. The time now is 15:42.