mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 21:21:32 +00:00
Fix zombie toolbars (bug 8520)
If there is a new toolbar, it will not be restored by Qt and we need to initialize it ourselves. However, it is not so easy to find out which toolbars are restored by Qt and which are not. For this, the setVisible function of GuiToolbar is 'misused'. If the visibility is set, the toolbar must have been restored by Qt and we should leave it alone.
This commit is contained in:
parent
97405fa623
commit
c8d685c665
@ -53,7 +53,8 @@ namespace frontend {
|
|||||||
|
|
||||||
GuiToolbar::GuiToolbar(ToolbarInfo const & tbinfo, GuiView & owner)
|
GuiToolbar::GuiToolbar(ToolbarInfo const & tbinfo, GuiView & owner)
|
||||||
: QToolBar(toqstr(tbinfo.gui_name), &owner), visibility_(0),
|
: QToolBar(toqstr(tbinfo.gui_name), &owner), visibility_(0),
|
||||||
owner_(owner), command_buffer_(0), tbinfo_(tbinfo), filled_(false)
|
owner_(owner), command_buffer_(0), tbinfo_(tbinfo), filled_(false),
|
||||||
|
restored_(false)
|
||||||
{
|
{
|
||||||
setIconSize(owner.iconSize());
|
setIconSize(owner.iconSize());
|
||||||
connect(&owner, SIGNAL(iconSizeChanged(QSize)), this,
|
connect(&owner, SIGNAL(iconSizeChanged(QSize)), this,
|
||||||
@ -68,6 +69,22 @@ GuiToolbar::GuiToolbar(ToolbarInfo const & tbinfo, GuiView & owner)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GuiToolbar::setVisible(bool visible)
|
||||||
|
{
|
||||||
|
// This is a hack to find out which toolbars have been restored by
|
||||||
|
// MainWindow::restoreState and which toolbars should be initialized
|
||||||
|
// by us (i.e., new toolbars)
|
||||||
|
restored_ = true;
|
||||||
|
QToolBar::setVisible(visible);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool GuiToolbar::isRestored() const
|
||||||
|
{
|
||||||
|
return restored_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void GuiToolbar::fill()
|
void GuiToolbar::fill()
|
||||||
{
|
{
|
||||||
if (filled_)
|
if (filled_)
|
||||||
|
@ -70,6 +70,10 @@ public:
|
|||||||
///
|
///
|
||||||
GuiToolbar(ToolbarInfo const &, GuiView &);
|
GuiToolbar(ToolbarInfo const &, GuiView &);
|
||||||
|
|
||||||
|
/// Reimplemented from QToolbar to detect whether the
|
||||||
|
/// toolbar is restored with MainWindow::restoreState().
|
||||||
|
void setVisible(bool visible);
|
||||||
|
|
||||||
///
|
///
|
||||||
void setVisibility(int visibility);
|
void setVisibility(int visibility);
|
||||||
|
|
||||||
@ -86,6 +90,9 @@ public:
|
|||||||
/// Restore session settings.
|
/// Restore session settings.
|
||||||
void restoreSession();
|
void restoreSession();
|
||||||
|
|
||||||
|
///
|
||||||
|
bool isRestored() const;
|
||||||
|
|
||||||
/// Refresh the contents of the bar.
|
/// Refresh the contents of the bar.
|
||||||
void update(bool in_math, bool in_table, bool review,
|
void update(bool in_math, bool in_table, bool review,
|
||||||
bool in_mathmacrotemplate, bool in_ipa);
|
bool in_mathmacrotemplate, bool in_ipa);
|
||||||
@ -123,6 +130,8 @@ private:
|
|||||||
ToolbarInfo const & tbinfo_;
|
ToolbarInfo const & tbinfo_;
|
||||||
///
|
///
|
||||||
bool filled_;
|
bool filled_;
|
||||||
|
///
|
||||||
|
bool restored_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace frontend
|
} // namespace frontend
|
||||||
|
@ -674,6 +674,16 @@ bool GuiView::restoreLayout()
|
|||||||
|
|
||||||
if (!restoreState(settings.value("layout").toByteArray(), 0))
|
if (!restoreState(settings.value("layout").toByteArray(), 0))
|
||||||
initToolbars();
|
initToolbars();
|
||||||
|
|
||||||
|
// init the toolbars that have not been restored
|
||||||
|
Toolbars::Infos::iterator cit = guiApp->toolbars().begin();
|
||||||
|
Toolbars::Infos::iterator end = guiApp->toolbars().end();
|
||||||
|
for (; cit != end; ++cit) {
|
||||||
|
GuiToolbar * tb = toolbar(cit->name);
|
||||||
|
if (tb && !tb->isRestored())
|
||||||
|
initToolbar(cit->name);
|
||||||
|
}
|
||||||
|
|
||||||
updateDialogs();
|
updateDialogs();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -716,11 +726,17 @@ void GuiView::initToolbars()
|
|||||||
// extracts the toolbars from the backend
|
// extracts the toolbars from the backend
|
||||||
Toolbars::Infos::iterator cit = guiApp->toolbars().begin();
|
Toolbars::Infos::iterator cit = guiApp->toolbars().begin();
|
||||||
Toolbars::Infos::iterator end = guiApp->toolbars().end();
|
Toolbars::Infos::iterator end = guiApp->toolbars().end();
|
||||||
for (; cit != end; ++cit) {
|
for (; cit != end; ++cit)
|
||||||
GuiToolbar * tb = toolbar(cit->name);
|
initToolbar(cit->name);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GuiView::initToolbar(string const & name)
|
||||||
|
{
|
||||||
|
GuiToolbar * tb = toolbar(name);
|
||||||
if (!tb)
|
if (!tb)
|
||||||
continue;
|
return;
|
||||||
int const visibility = guiApp->toolbars().defaultVisibility(cit->name);
|
int const visibility = guiApp->toolbars().defaultVisibility(name);
|
||||||
bool newline = !(visibility & Toolbars::SAMEROW);
|
bool newline = !(visibility & Toolbars::SAMEROW);
|
||||||
tb->setVisible(false);
|
tb->setVisible(false);
|
||||||
tb->setVisibility(visibility);
|
tb->setVisibility(visibility);
|
||||||
@ -752,7 +768,6 @@ void GuiView::initToolbars()
|
|||||||
if (visibility & Toolbars::ON)
|
if (visibility & Toolbars::ON)
|
||||||
tb->setVisible(true);
|
tb->setVisible(true);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
TocModels & GuiView::tocModels()
|
TocModels & GuiView::tocModels()
|
||||||
|
@ -344,6 +344,8 @@ private:
|
|||||||
///
|
///
|
||||||
void initToolbars();
|
void initToolbars();
|
||||||
///
|
///
|
||||||
|
void initToolbar(std::string const & name);
|
||||||
|
///
|
||||||
bool lfunUiToggle(std::string const & ui_component);
|
bool lfunUiToggle(std::string const & ui_component);
|
||||||
///
|
///
|
||||||
void toggleFullScreen();
|
void toggleFullScreen();
|
||||||
|
Loading…
Reference in New Issue
Block a user