]> git.lyx.org Git - features.git/commitdiff
* GuiApplication.C: align Windows with other platform. No more static trick!
authorAbdelrazak Younes <younes@lyx.org>
Thu, 12 Oct 2006 22:02:45 +0000 (22:02 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Thu, 12 Oct 2006 22:02:45 +0000 (22:02 +0000)
* 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

src/frontends/qt4/GuiApplication.C
src/lyx_main.C
src/lyx_main.h

index f3c8421f62b3aa39f763a799bf8f945c1548ab1f..fb50274b570c3aa6a928fbe2939bda2523f8da00 100644 (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
 }
 
 
index 2d1a08489e2c0f7375571d9c923e05db78e1ec1b..9da0098cbf0102f35afe3cfc1037eb4126dc5381 100644 (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();
 }
 
 
index c40232f4546ded994f22e8dcc119618fba103293..8f51d818b2d645bdbc38539a460d16e4dfd0f316 100644 (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