Date:2013-08-16 10:41:16 (10 years 7 months ago)
Author:Maarten ter Huurne
Commit:965340a39c12cd62b3485b4a97c30984c62f6aaf
Message:Fixed bug with launch screen and double buffering

LinkApp::drawRun() assumes the layers below are already painted when
it is called, but this was not the case. With single buffering, the
previous frame was still there so it still looked good, but with
double buffering the buffer typically contains an outdated screen.

Long term I think the launch should happen at the outermost scope,
so all destructors get a chance to run. This commit is a small step
in that direction, by exiting the main loop before launching.
Files: src/gmenu2x.cpp (5 diffs)
src/gmenu2x.h (3 diffs)
src/linkapp.cpp (2 diffs)
src/linkapp.h (3 diffs)

Change Details

src/gmenu2x.cpp
194194#endif
195195
196196GMenu2X::GMenu2X()
197    : appToLaunch(nullptr)
197198{
198199    usbnet = samba = inet = web = false;
199200    useSelectionPng = false;
...... 
589590    if (!fileExists(CARD_ROOT))
590591        CARD_ROOT = "";
591592
592    bool quit = false;
593    while (!quit) {
593    appToLaunch = nullptr;
594
595    while (true) {
594596        // Remove dismissed layers from the stack.
595597        for (auto it = layers.begin(); it != layers.end(); ) {
596598            if ((*it)->getStatus() == Layer::Status::DISMISSED) {
...... 
610612        for (auto layer : layers) {
611613            layer->paint(*s);
612614        }
615        if (appToLaunch) {
616            break;
617        }
613618        s->flip();
614619
615620        // Handle touchscreen events.
...... 
639644            }
640645        }
641646    }
647
648    if (appToLaunch) {
649        appToLaunch->drawRun();
650        appToLaunch->launch(fileToLaunch);
651    }
642652}
643653
644654void GMenu2X::explorer() {
...... 
662672    }
663673}
664674
675void GMenu2X::queueLaunch(LinkApp *app, const std::string &file) {
676    appToLaunch = app;
677    fileToLaunch = file;
678}
679
665680void GMenu2X::showHelpPopup() {
666681    layers.push_back(make_shared<HelpPopup>(*this));
667682}
src/gmenu2x.h
3939class HelpPopup;
4040class IconButton;
4141class Layer;
42class LinkApp;
4243class MediaMonitor;
4344class Menu;
4445class Surface;
...... 
7273    std::shared_ptr<Menu> menu;
7374    MediaMonitor *monitor;
7475
76    LinkApp *appToLaunch;
77    std::string fileToLaunch;
78
7579    std::vector<std::shared_ptr<Layer>> layers;
7680
7781    /*!
...... 
184188
185189    void setInputSpeed();
186190
191    /**
192     * Requests that the given application be launched.
193     * The launch won't happen immediately; it will happen after control
194     * returns to the main loop.
195     */
196    void queueLaunch(LinkApp *app, const std::string &file);
187197    void saveSelection();
188198    void writeConfig();
189199    void writeSkinConfig();
src/linkapp.cpp
372372    if (!selectordir.empty())
373373        selector();
374374    else
375        launch();
375        gmenu2x->queueLaunch(this, "");
376376}
377377
378378void LinkApp::showManual() {
...... 
547547            selectordir = selectedDir;
548548        }
549549        gmenu2x->writeTmp(selection, selectedDir);
550        launch(selectedDir + sel.getFile());
550        gmenu2x->queueLaunch(this, selectedDir + sel.getFile());
551551    }
552552}
553553
554554void LinkApp::launch(const string &selectedFile) {
555    drawRun();
556
557555    save();
558556
559557    if (isOpk()) {
src/linkapp.h
4141    int iclock;
4242    std::string exec, params, workdir, manual, selectordir, selectorfilter, selectorscreens;
4343    bool selectorbrowser, editable;
44    void drawRun();
4544
4645    std::string aliasfile;
4746    std::string file;
...... 
5352#endif
5453
5554    void start();
56    void launch(const std::string &selectedFile = "");
5755
5856protected:
5957    virtual const std::string &searchIcon();
...... 
107105
108106    const std::string &getFile() { return file; }
109107    void renameFile(const std::string &name);
108
109    void drawRun();
110    void launch(const std::string &selectedFile);
110111};
111112
112113#endif

Archive Download the corresponding diff file



interactive