Attempting to get rid of the BufferView cache stuff, I've had a look 
at class LyX. It is simple enough to turn it into a singleton class

class LyX : boost::noncopyable {
        static void init(int & argc, char * argv[]);
        static LyX const & get();
private:
        LyX(int & argc, char * argv[]);
};

namespace {
        boost::scoped_ptr<LyX> singleton;
} // namespace anon

void LyX::init(int & argc, char * argv[]) {
        BOOST_ASSERT(!singleton.get());
        singleton.reset(new LyX(argc, argv));
}

LyX const & LyX::get() {
        BOOST_ASSERT(singleton.get());
        return *singleton.get();
}


But this doesn't actually help because it doesn't actually own any 
LyXViews!

In fact, further investigation shows that we have lyx_gui::start:

namespace {
        bool finished = false
} // namespace anon

void start(string const & batch, vector<string> const & files) {
        ...
        XFormsView view(width, height);
        view.show(xpos, ypos, "LyX");
        view.init();

        ...
        // enter the event loop
        while (!finished) {
                if (fl_check_forms() == FL_EVENT) {
                        XEvent ev;
                        fl_XNextEvent(&ev);
                }
        }

        // FIXME: breaks emergencyCleanup
        delete lyxsocket;
        delete lyxserver;
}

I propose to store 
        std::list<boost::shared_ptr<LyXView> > lyxviews_;

within LyX and to continue the event loop with the equivalent of
        while (!LyX::get().lyxviews_.empty())

Obviously, for now, there will only ever be one item in this list, but 
at least this item would now be accessible.

Regards,
Angus

Reply via email to