Fixed a possible crash at startup.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@5311 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2012-07-17 22:16:56 +00:00
parent cda4adbf5b
commit 47d652b4ec

View File

@ -57,12 +57,13 @@
int main(int argc, char *argv[])
{
QApplication *dummyApp = new QApplication(argc, argv); // memory leak in case of an error in main
#ifdef WINDOWS_SYS
/* Set the current directory to the application dir,
because the start dir with autostart from the registry run key is not the exe dir */
QDir::setCurrent(QCoreApplication::applicationDirPath());
{
/* Set the current directory to the application dir,
because the start dir with autostart from the registry run key is not the exe dir */
QApplication app(argc, argv);
QDir::setCurrent(QCoreApplication::applicationDirPath());
}
#endif
QStringList args = char_array_to_stringlist(argv+1, argc-1);
@ -75,15 +76,16 @@ int main(int argc, char *argv[])
createRsIface(*notify);
createRsControl(*rsiface, *notify);
/* Translate into the desired language */
LanguageSupport::translate(LanguageSupport::defaultLanguageCode());
/* RetroShare Core Objects */
RsInit::InitRsConfig();
int initResult = RsInit::InitRetroShare(argc, argv);
if(initResult == RS_INIT_NO_KEYRING) // happens when we already have accounts, but no pgp key. This is when switching to the openpgp-sdk version.
{
QApplication dummyApp (argc, argv); // needed for QMessageBox
/* Translate into the desired language */
LanguageSupport::translate(LanguageSupport::defaultLanguageCode());
QMessageBox msgBox;
msgBox.setText(QObject::tr("This version of RetroShare is using OpenPGP-SDK. As a side effect, it's not using the system shared PGP keyring, but has it's own keyring shared by all RetroShare instances. <br><br>You do not appear to have such a keyring, although GPG keys are mentionned by existing RetroShare accounts, probably because you just changed to this new version of the software."));
msgBox.setInformativeText(QObject::tr("Choose between:<br><ul><li><b>Ok</b> to copy the existing keyring from gnupg (safest bet), or </li><li><b>Close without saving</b> to start fresh with an empty keyring (you will be asked to create a new PGP key to work with RetroShare, or import a previously saved pgp keypair). </li><li><b>Cancel</b> to quit and forge a keyring by yourself (needs some PGP skills)</li></ul>"));
@ -108,6 +110,10 @@ int main(int argc, char *argv[])
if (initResult < 0) {
/* Error occured */
QApplication dummyApp (argc, argv); // needed for QMessageBox
/* Translate into the desired language */
LanguageSupport::translate(LanguageSupport::defaultLanguageCode());
QMessageBox mb(QMessageBox::Critical, QObject::tr("RetroShare"), "", QMessageBox::Ok);
mb.setWindowIcon(QIcon(":/images/rstray3.png"));
@ -133,7 +139,6 @@ int main(int argc, char *argv[])
RshareSettings::Create ();
/* Setup The GUI Stuff */
delete dummyApp;
Rshare rshare(args, argc, argv,
QString::fromUtf8(RsInit::RsConfigDirectory().c_str()));