* GuiApplication.C: align Windows with other platform. No more static trick!

* lyx_main:
  - LyX::application_ : new scoped_ptr member containing the Application instance.
  - LyX::priv_exec(): initialize application_.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15316 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Abdelrazak Younes 2006-10-12 22:02:45 +00:00
parent 21316375fe
commit 53bbb6ed7a
3 changed files with 16 additions and 17 deletions

View File

@ -75,15 +75,7 @@ namespace lyx {
lyx::frontend::Application * createApplication(int & argc, char * argv[])
{
// FIXME: it would be great if we could just do:
//return new lyx::frontend::GuiApplication(argc, argv);
#if defined(Q_WS_WIN) && !defined(Q_CYGWIN_WIN)
static lyx::frontend::GuiApplication app(argc, argv);
return &app;
#else
return new lyx::frontend::GuiApplication(argc, argv);
#endif
}

View File

@ -256,13 +256,14 @@ int LyX::priv_exec(int & argc, char * argv[])
if (lyx::use_gui) {
// Force adding of font path _before_ Application is initialized
lyx::support::addFontResources();
theApp = lyx::createApplication(argc, argv);
application_.reset(lyx::createApplication(argc, argv));
theApp = application_.get();
}
else {
// FIXME: create a ConsoleApplication
theApp = 0;
}
return exec2(argc, argv);
}
@ -378,7 +379,7 @@ int LyX::exec2(int & argc, char * argv[])
height = 0;
}
// create the main window
LyXView * view = &theApp->createView(width, height, posx, posy, maximize);
LyXView * view = &application_->createView(width, height, posx, posy, maximize);
ref().addLyXView(view);
// load files
@ -397,7 +398,7 @@ int LyX::exec2(int & argc, char * argv[])
// clear this list to save a few bytes of RAM
session_->clearLastOpenedFiles();
return theApp->start(batch_command);
return application_->start(batch_command);
} else {
// Something went wrong above
quitLyX(false);
@ -534,15 +535,15 @@ bool LyX::init()
if (lyxrc.roman_font_name.empty())
lyxrc.roman_font_name =
lyx::use_gui? theApp->romanFontName(): "serif";
lyx::use_gui? application_->romanFontName(): "serif";
if (lyxrc.sans_font_name.empty())
lyxrc.sans_font_name =
lyx::use_gui? theApp->sansFontName(): "sans";
lyx::use_gui? application_->sansFontName(): "sans";
if (lyxrc.typewriter_font_name.empty())
lyxrc.typewriter_font_name =
lyx::use_gui? theApp->typewriterFontName(): "monospace";
lyx::use_gui? application_->typewriterFontName(): "monospace";
//
// Read configuration files
@ -705,7 +706,7 @@ void LyX::emergencyCleanup() const
// a crash
theBufferList().emergencyWriteAll();
theApp->server().emergencyCleanup();
application_->server().emergencyCleanup();
}

View File

@ -27,8 +27,12 @@ class ErrorItem;
class InsetBase;
class LyXView;
class kb_keymap;
namespace lyx {
class Session;
class Session;
namespace frontend {
class Application;
}
}
@ -118,6 +122,8 @@ private:
///
bool geometryOption_;
///
boost::scoped_ptr<lyx::frontend::Application> application_;
};
#endif // LYX_MAIN_H