[apps/code][python] ConsoleController doesn't keep any pointer/boolean to know

if the sandbox/matplotlib view controller is displayed. Its state won't be
always right; instead, use the StackViewController depth.

This fixes the following bug: when popping the sandbox/matplotlib view
controller, the first responder token was not given to the console
controller!
This commit is contained in:
Émilie Feral
2020-03-26 09:42:36 +01:00
parent d0c5ac0343
commit fb3f6ab6f3
9 changed files with 35 additions and 54 deletions

View File

@@ -28,7 +28,7 @@ static size_t extractAndValidatePlotInput(mp_obj_t x, mp_obj_t y, mp_obj_t ** xI
mp_obj_t modpyplot___init__() {
static Matplotlib::PlotStore plotStore;
static Matplotlib::PlotController plotController(&plotStore, MicroPython::ExecutionEnvironment::currentExecutionEnvironment());
static Matplotlib::PlotController plotController(&plotStore);
sPlotStore = &plotStore;
sPlotController = &plotController;
sPlotStore->flush();

View File

@@ -3,12 +3,10 @@
namespace Matplotlib {
void PlotController::viewWillAppear() {
MicroPython::ExecutionViewControllerHelper::viewWillAppear(this);
curveView()->reload();
}
void PlotController::viewDidDisappear() {
MicroPython::ExecutionViewControllerHelper::viewDidDisappear(this);
m_store->flush();
}

View File

@@ -2,15 +2,14 @@
#define PYTHON_MATPLOTLIB_PLOT_CONTROLLER_H
#include <apps/shared/zoom_and_pan_curve_view_controller.h>
#include <python/port/port.h>
#include "plot_view.h"
#include "plot_store.h"
namespace Matplotlib {
class PlotController : public Shared::ZoomAndPanCurveViewController, public MicroPython::ExecutionViewControllerHelper {
class PlotController : public Shared::ZoomAndPanCurveViewController {
public:
PlotController(PlotStore * store, MicroPython::ExecutionEnvironment * executiveEnvironment) : Shared::ZoomAndPanCurveViewController(nullptr), ExecutionViewControllerHelper(executiveEnvironment), m_store(store), m_view(m_store) {}
PlotController(PlotStore * store) : Shared::ZoomAndPanCurveViewController(nullptr), m_store(store), m_view(m_store) {}
void viewWillAppear() override;
void viewDidDisappear() override;