bug fixed: app crashed whet 'plugins' dir was absent

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@982 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
beardog_uk 2009-02-02 15:31:34 +00:00
parent ed2d622ded
commit 1b6376bc65

View File

@ -37,7 +37,9 @@ PluginsPage::PluginsPage(QWidget *parent )
pluginPanelLayout->addWidget(pluginTabs); pluginPanelLayout->addWidget(pluginTabs);
QLabel* lbl1 = new QLabel(); QLabel* lbl1 = new QLabel();
lbl1->setText("If you see only this tab, it's a bug :( If you see this tub and calculator, it's a bug too"); QString defMess = "If you see only this tab, it's a bug :(\n";
defMess+= "If you see this tub and calculator, it's a bug too";
lbl1->setText(defMess);
pluginTabs->addTab(lbl1, "LLL");//Rshare::dataDirectory()); pluginTabs->addTab(lbl1, "LLL");//Rshare::dataDirectory());
//"L #1"); //"L #1");
@ -45,23 +47,13 @@ PluginsPage::PluginsPage(QWidget *parent )
//lbl2->setText("Label #2"); //lbl2->setText("Label #2");
//pluginTabs->addTab(lbl2, "L #2; for debugging purposes"); //pluginTabs->addTab(lbl2, "L #2; for debugging purposes");
QDir pluginsDir(Rshare::dataDirectory()); QDir pluginsDir(Rshare::dataDirectory() + "/plugins");
// this piece of code is magical and untested ; if ( !pluginsDir.exists() )
// but on Windows it works {
#if defined(Q_OS_WIN) lbl1->setText("failed to locate 'plugins' directory. Nothing to load" );
if (pluginsDir.dirName().toLower() == "debug" || pluginsDir.dirName().toLower() == "release") return ;
pluginsDir.cdUp();
#elif defined(Q_OS_MAC)
if (pluginsDir.dirName() == "MacOS") {
pluginsDir.cdUp();
pluginsDir.cdUp();
pluginsDir.cdUp();
} }
#endif
// eof magick
pluginsDir.cd("plugins");
foreach (QString fileName, pluginsDir.entryList(QDir::Files)) foreach (QString fileName, pluginsDir.entryList(QDir::Files))
{ {
@ -95,9 +87,17 @@ PluginsPage::PluginsPage(QWidget *parent )
} }
// script plugins loading; warning, code is dirty; will be changed later // script plugins loading; warning, code is dirty; will be changed later
engine = new QScriptEngine; engine = new QScriptEngine(parent);
pluginsDir.cd("../script_plugins"); pluginsDir.setPath(Rshare::dataDirectory() + "/script_plugins");
if ( !pluginsDir.exists() )
{
QString tmps = lbl1->text();
tmps += " Failed to locate 'script_plugins' directory. " ;
lbl1->setText( tmps);
return ;
}
@ -155,7 +155,7 @@ PluginsPage::PluginsPage(QWidget *parent )
//ui->show(); //ui->show();
pluginTabs->addTab(ui,"Script plugin"); pluginTabs->addTab(ui,"Script plugin");
} }
//What has a head like a cat, feet like a cat, a tail like a cat, but isn't a cat?
} }
} }
@ -165,6 +165,6 @@ PluginsPage::PluginsPage(QWidget *parent )
PluginsPage::~PluginsPage() PluginsPage::~PluginsPage()
{ {
// nothing to do here at this moment // nothing to do here at this moment
delete engine; //delete engine;
} }