Fixes broken selection of WB, crop and straighten from toolbar (#5286)

Improvements:
- When switching between notebook pages different from Locallab one,
edit tools aren't anymore unsubscribed for better robustness
This commit is contained in:
Pandagrapher
2019-04-20 18:43:56 +02:00
parent 853a6f0e2c
commit 3423e45753
2 changed files with 18 additions and 1 deletions

View File

@@ -273,6 +273,8 @@ ToolPanelCoordinator::ToolPanelCoordinator (bool batch) : ipc (nullptr), favorit
toolBar = new ToolBar(); toolBar = new ToolBar();
toolBar->setToolBarListener(this); toolBar->setToolBarListener(this);
prevPage = toolPanelNotebook->get_nth_page(0);
} }
void ToolPanelCoordinator::notebookPageChanged(Gtk::Widget* page, guint page_num) void ToolPanelCoordinator::notebookPageChanged(Gtk::Widget* page, guint page_num)
@@ -283,10 +285,14 @@ void ToolPanelCoordinator::notebookPageChanged(Gtk::Widget* page, guint page_num
if (page == locallabPanelSW) { if (page == locallabPanelSW) {
toolBar->blockEditDeactivation(); // Avoid edit tool deactivation when Locallab page is active (except if pressing other tools button) toolBar->blockEditDeactivation(); // Avoid edit tool deactivation when Locallab page is active (except if pressing other tools button)
locallab->subscribe(); locallab->subscribe();
} else { }
if (prevPage == locallabPanelSW) { // To deactivate Locallab only when switching from Locallab page
toolBar->blockEditDeactivation(false); toolBar->blockEditDeactivation(false);
locallab->unsubscribe(); locallab->unsubscribe();
} }
prevPage = page;
} }
} }
@@ -1053,26 +1059,36 @@ void ToolPanelCoordinator::toolSelected(ToolMode tool)
{ {
GThreadLock lock; // All GUI access from idle_add callbacks or separate thread HAVE to be protected GThreadLock lock; // All GUI access from idle_add callbacks or separate thread HAVE to be protected
notebookconn.block(true); // "signal_switch_page" event is blocked to avoid unsubscribing Locallab (allows a correct behavior when switching to another tool using toolbar)
switch (tool) { switch (tool) {
case TMCropSelect: case TMCropSelect:
toolBar->blockEditDeactivation(false); // To allow deactivating Locallab when switching to another tool using toolbar
crop->setExpanded(true); crop->setExpanded(true);
toolPanelNotebook->set_current_page(toolPanelNotebook->page_num(*transformPanelSW)); toolPanelNotebook->set_current_page(toolPanelNotebook->page_num(*transformPanelSW));
prevPage = toolPanelNotebook->get_nth_page(toolPanelNotebook->get_current_page()); // Updating prevPage as "signal_switch_page" event
break; break;
case TMSpotWB: case TMSpotWB:
toolBar->blockEditDeactivation(false); // To allow deactivating Locallab when switching to another tool using toolbar
whitebalance->setExpanded(true); whitebalance->setExpanded(true);
toolPanelNotebook->set_current_page(toolPanelNotebook->page_num(*colorPanelSW)); toolPanelNotebook->set_current_page(toolPanelNotebook->page_num(*colorPanelSW));
prevPage = toolPanelNotebook->get_nth_page(toolPanelNotebook->get_current_page()); // Updating prevPage as "signal_switch_page" event
break; break;
case TMStraighten: case TMStraighten:
toolBar->blockEditDeactivation(false); // To allow deactivating Locallab when switching to another tool using toolbar
lensgeom->setExpanded(true); lensgeom->setExpanded(true);
rotate->setExpanded(true); rotate->setExpanded(true);
toolPanelNotebook->set_current_page(toolPanelNotebook->page_num(*transformPanelSW)); toolPanelNotebook->set_current_page(toolPanelNotebook->page_num(*transformPanelSW));
prevPage = toolPanelNotebook->get_nth_page(toolPanelNotebook->get_current_page()); // Updating prevPage as "signal_switch_page" event
break; break;
default: default:
break; break;
} }
notebookconn.block(false);
} }
void ToolPanelCoordinator::editModeSwitchedOff() void ToolPanelCoordinator::editModeSwitchedOff()

View File

@@ -207,6 +207,7 @@ private:
EditDataProvider *editDataProvider; EditDataProvider *editDataProvider;
sigc::connection notebookconn; sigc::connection notebookconn;
bool photoLoadedOnce; // Used to indicated that a photo has been loaded yet bool photoLoadedOnce; // Used to indicated that a photo has been loaded yet
Gtk::Widget* prevPage;
public: public:
CoarsePanel* coarse; CoarsePanel* coarse;