summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Bauer2011-01-27 12:52:03 +0100
committerJonathan Bauer2011-01-27 12:52:03 +0100
commitf28a388c9952961e870bf036ec0e28f4737ed21f (patch)
tree72bcaecaf4d87830661f390196bd43b8849665b8
parentfixed a few things... (diff)
downloadfbgui-f28a388c9952961e870bf036ec0e28f4737ed21f.tar.gz
fbgui-f28a388c9952961e870bf036ec0e28f4737ed21f.tar.xz
fbgui-f28a388c9952961e870bf036ec0e28f4737ed21f.zip
changed getPath() function, now uses /proc/self/exe to get the path.
-rw-r--r--src/fbbrowser.cpp2
-rw-r--r--src/fbgui.cpp19
2 files changed, 11 insertions, 10 deletions
diff --git a/src/fbbrowser.cpp b/src/fbbrowser.cpp
index bd2eb8e..5495a78 100644
--- a/src/fbbrowser.cpp
+++ b/src/fbbrowser.cpp
@@ -6,7 +6,7 @@
void fbbrowser::httpReadyRead()
{
// This slot listens to readyRead() signal from our QNetworkReply.
- qDebug() << "readyRead() signal emmited!" << endl;
+ qDebug() << "finished() signal emmited!" << endl;
if(reply->error() == QNetworkReply::NoError)
{
qDebug() << "No error, loading given URL...";
diff --git a/src/fbgui.cpp b/src/fbgui.cpp
index fe67b79..825af9c 100644
--- a/src/fbgui.cpp
+++ b/src/fbgui.cpp
@@ -6,6 +6,9 @@
#include <getopt.h>
#include <fbgui.h>
+#include <string>
+#include <limits.h>
+#include <unistd.h>
void printUsage()
{
@@ -20,14 +23,11 @@ void printUsage()
exit(1);
}
-QString getPath(const char* c)
+std::string getPath()
{
- QString appPath = c;
- // Locate last '/' in the full path and remove all the chars after it.
- appPath.chop(appPath.length() - 1
- - appPath.lastIndexOf("/", appPath.length()-1));
- qDebug() << "Application path: " << appPath;
- return appPath;
+ char result[ PATH_MAX ];
+ size_t count = readlink("/proc/self/exe", result, PATH_MAX);
+ return std::string( result, (count > 0) ? count : 0);
}
int main(int argc, char *argv[])
@@ -59,12 +59,13 @@ int main(int argc, char *argv[])
}
opt = getopt_long(argc, argv, optString, longOpts, &longIndex);
}
+ // Get the application path and prints on screen.
+ std::string appPath = getPath();
+ std::cout << "Application path: " << appPath << endl;
// This is the main object of a QT Application.
QApplication a(argc, argv);
// Is this really needed, since we kill the app through the fbbrowser object?
QObject::connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()));
- // Get the application path.
- QString appPath = getPath(argv[0]);
// This part reads the URL to load from the arguments given through the commandline.
QUrl url;
if (argc > 1)