mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-09-14 20:33:05 +02:00
Fix crash: In Xref link widget, If there is an element being added (element pose mode), and this one is compatible with the type of Xref sought by the widget, then the widget show this element.
When user finish the element pose mode, the element under the cursor is deleted, but continue to be show by the widget. So, click on this element in the widget cause a crash. This case come when user add element and go to another diagram without finish the pose mode, and open Xref link widget from an element in this other diagram. git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@4993 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
parent
4c56ebf353
commit
a69e39cd2f
@ -377,8 +377,6 @@ void Diagram::keyReleaseEvent(QKeyEvent *e)
|
||||
* Diagram become the ownership of event_interface
|
||||
* If there is a previous interface, they will be delete before
|
||||
* and call init() to the new interface.
|
||||
* The derivated class of DiagramEventInterface need to emit the signal "finish" when the job is done,
|
||||
* diagram use this signal to delete the interface. If the signal isn't send, the interface will never be deleted.
|
||||
* @param event_interface
|
||||
*/
|
||||
void Diagram::setEventInterface(DiagramEventInterface *event_interface)
|
||||
@ -391,6 +389,19 @@ void Diagram::setEventInterface(DiagramEventInterface *event_interface)
|
||||
m_event_interface = event_interface;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Diagram::clearEventInterface
|
||||
* Clear the current event interface.
|
||||
*/
|
||||
void Diagram::clearEventInterface()
|
||||
{
|
||||
if(m_event_interface)
|
||||
{
|
||||
delete m_event_interface;
|
||||
m_event_interface = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Diagram::conductorsAutonumName
|
||||
* @return the name of autonum to use.
|
||||
|
@ -129,6 +129,7 @@ class Diagram : public QGraphicsScene
|
||||
|
||||
public:
|
||||
void setEventInterface (DiagramEventInterface *event_interface);
|
||||
void clearEventInterface();
|
||||
|
||||
//methods related to autonum
|
||||
QString conductorsAutonumName() const;
|
||||
|
@ -989,15 +989,22 @@ void ProjectView::rebuildDiagramsMap() {
|
||||
* we display the fallback widget.
|
||||
* @param tab_id
|
||||
*/
|
||||
void ProjectView::tabChanged(int tab_id) {
|
||||
void ProjectView::tabChanged(int tab_id)
|
||||
{
|
||||
if (tab_id == -1)
|
||||
setDisplayFallbackWidget(true);
|
||||
else if(m_tab->count() == 1)
|
||||
setDisplayFallbackWidget(false);
|
||||
|
||||
emit(diagramActivated(m_diagram_ids[tab_id]));
|
||||
|
||||
if (m_diagram_ids[tab_id] != nullptr)
|
||||
m_diagram_ids[tab_id]->diagram()->diagramActivated();
|
||||
|
||||
//Clear the event interface of the previous diagram
|
||||
if (DiagramView *dv = m_diagram_ids[m_previous_tab_index])
|
||||
dv->diagram()->clearEventInterface();
|
||||
m_previous_tab_index = tab_id;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -133,6 +133,7 @@ class ProjectView : public QWidget
|
||||
QLabel *fallback_label_;
|
||||
QTabWidget *m_tab;
|
||||
QMap<int, DiagramView *> m_diagram_ids;
|
||||
int m_previous_tab_index = -1;
|
||||
QList<DiagramView *> m_diagram_view_list;
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user