]> git.llucax.com Git - z.facultad/75.42/plaqui.git/commitdiff
arreglo miles de bugs que me hicieron cambiar muchas cosas que no eran necesarias...
authorNicolás Dimov <ndimov@gmail.com>
Thu, 20 Nov 2003 06:44:16 +0000 (06:44 +0000)
committerNicolás Dimov <ndimov@gmail.com>
Thu, 20 Nov 2003 06:44:16 +0000 (06:44 +0000)
Constructor/include/workplace.h
Constructor/src/and.cpp
Constructor/src/cistern.cpp
Constructor/src/exclusa.cpp
Constructor/src/not.cpp
Constructor/src/or.cpp
Constructor/src/pump.cpp
Constructor/src/workplace.cpp

index db4b3ce5b7a96c79cb4659fc8300a7a12a1a3122..c4dfc94f63adebc76d788bb8861b64893f407caa 100644 (file)
@@ -9,7 +9,7 @@
 class CItem;
 
 typedef struct {
 class CItem;
 
 typedef struct {
-       CItem *logic, *store;
+       int logic_id, store_id;
 }t_line;
 
 class WorkPlace:public Gtk::Fixed {
 }t_line;
 
 class WorkPlace:public Gtk::Fixed {
@@ -20,6 +20,7 @@ class WorkPlace:public Gtk::Fixed {
                void delete_item(int _id);
                void delete_line(int _id);      
                CItem *get_logic_item(int _id);
                void delete_item(int _id);
                void delete_line(int _id);      
                CItem *get_logic_item(int _id);
+               CItem *get_item(int _id);
                void update_logic_position();
                std::list<CItem *> *listaItems, *lista_logic_Items;
                /** Listas de lineas que van de una compuerta a la entrada de un item y de la salida de un item a una compuerta
                void update_logic_position();
                std::list<CItem *> *listaItems, *lista_logic_Items;
                /** Listas de lineas que van de una compuerta a la entrada de un item y de la salida de un item a una compuerta
index fbee4121cc32b6028fd85d251997a48bc4011363..4e0534ebe312a1176562e99e0a37f428dcfb8cec 100644 (file)
@@ -25,10 +25,12 @@ And::~And()
 bool And::on_button_press_event(GdkEventButton *event)
 {
        if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 1)) {
 bool And::on_button_press_event(GdkEventButton *event)
 {
        if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 1)) {
-               CItem::logic_connect = true;
-               CItem::gate_id = ID;
+               if ( CItem::logic_connect ) {
+                       CItem::gate_id = ID;
+                       WorkPlace::pointed = ID;
+               }
                combo_entry->set_text(name);
                combo_entry->set_text(name);
-               WorkPlace::pointed = ID;
+               
        }
        
        if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 2)){
        }
        
        if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 2)){
@@ -99,7 +101,7 @@ void And::save(FILE *archivo)
        dato += c_img;
        dato += c_x;
        dato += c_y;
        dato += c_img;
        dato += c_x;
        dato += c_y;
-       for ( int i=0; i<=vec_connector.size()-1; i++) {
+       for ( int i=0; i<=vec_connector.size()-1&&!vec_connector.empty(); i++) {
                if ( vec_connector[i].type == IN ) {
                        dato += "\t\t<entrada>";
                        dato += vec_connector[i].name_dest + "</entrada>\n";
                if ( vec_connector[i].type == IN ) {
                        dato += "\t\t<entrada>";
                        dato += vec_connector[i].name_dest + "</entrada>\n";
@@ -118,9 +120,9 @@ bool And::check_connection()
        t_logic_connector temp;
        std::list<t_line>::iterator i = workplace->lista_lineas_in.begin();
        while ( i != workplace->lista_lineas_in.end() ) {
        t_logic_connector temp;
        std::list<t_line>::iterator i = workplace->lista_lineas_in.begin();
        while ( i != workplace->lista_lineas_in.end() ) {
-               if ( (*i).logic->get_id() == ID ) {
+               if ( workplace->get_logic_item((*i).logic_id)->get_id() == ID ) {
                        temp.type = OUT;
                        temp.type = OUT;
-                       temp.name_dest = (*i).store->get_name();
+                       temp.name_dest = workplace->get_item((*i).store_id)->get_name();
                        vec_connector.push_back(temp);
                        cant_out++;
                }
                        vec_connector.push_back(temp);
                        cant_out++;
                }
@@ -129,9 +131,9 @@ bool And::check_connection()
 
        i = workplace->lista_lineas_out.begin();
        while ( i != workplace->lista_lineas_out.end() ) {
 
        i = workplace->lista_lineas_out.begin();
        while ( i != workplace->lista_lineas_out.end() ) {
-               if ( (*i).logic->get_id() == ID ) {
+               if ( workplace->get_logic_item((*i).logic_id)->get_id() == ID ) {
                        temp.type = IN;
                        temp.type = IN;
-                       temp.name_dest = (*i).store->get_name();
+                       temp.name_dest = workplace->get_item((*i).store_id)->get_name();
                        vec_connector.push_back(temp);
                        cant_in++;
                }
                        vec_connector.push_back(temp);
                        cant_in++;
                }
index 5ad6ecb985542211229765ec4d3af3dc53440095..2f7a02c0b17cf09d603057637a2780c672890489 100644 (file)
@@ -46,15 +46,15 @@ bool Cistern::on_button_press_event(GdkEventButton *event)
        if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 1)) {
                combo_entry->set_text(name);
                WorkPlace::pointed = ID;
        if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 1)) {
                combo_entry->set_text(name);
                WorkPlace::pointed = ID;
-               if (CItem::logic_connect) {
+               if (CItem::logic_connect && CItem::gate_id != -1) {
                        if ( detect_click_position(event->x, event->y) == IN ){
                        if ( detect_click_position(event->x, event->y) == IN ){
-                               tmp_line.logic =  workplace->get_logic_item(CItem::gate_id);
-                               tmp_line.store = this;
+                               tmp_line.logic_id =  workplace->get_logic_item(CItem::gate_id)->get_id();
+                               tmp_line.store_id = ID;
                                workplace->lista_lineas_in.push_back(tmp_line);
                                workplace->queue_draw();
                        } else if (detect_click_position(event->x, event->y) == OUT) { 
                                workplace->lista_lineas_in.push_back(tmp_line);
                                workplace->queue_draw();
                        } else if (detect_click_position(event->x, event->y) == OUT) { 
-                               tmp_line.logic =  workplace->get_logic_item(CItem::gate_id);
-                               tmp_line.store = this;
+                               tmp_line.logic_id =  workplace->get_logic_item(CItem::gate_id)->get_id();
+                               tmp_line.store_id = ID;
                                workplace->lista_lineas_out.push_back(tmp_line);
                                workplace->queue_draw();
                        }
                                workplace->lista_lineas_out.push_back(tmp_line);
                                workplace->queue_draw();
                        }
@@ -96,7 +96,6 @@ bool Cistern::on_button_press_event(GdkEventButton *event)
                cistern_pty_wnd->txt_cistern_name->set_text( name );
                cistern_pty_wnd->show();
        }               
                cistern_pty_wnd->txt_cistern_name->set_text( name );
                cistern_pty_wnd->show();
        }               
-       CItem::logic_connect =false;
        workplace->queue_draw();
        return true;
 }
        workplace->queue_draw();
        return true;
 }
index 365b6e45675355de3b1a6a41659f028849952ad6..ee75ed5dc76096cc9ad9b23cee0adcc998334c62 100644 (file)
@@ -43,15 +43,15 @@ bool Exclusa::on_button_press_event(GdkEventButton *event)
        if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 1)) {
                combo_entry->set_text(name);
                WorkPlace::pointed = ID;
        if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 1)) {
                combo_entry->set_text(name);
                WorkPlace::pointed = ID;
-               if (CItem::logic_connect) {
+               if (CItem::logic_connect && CItem::gate_id != -1) {
                        if ( detect_click_position(event->x, event->y) == IN) {
                        if ( detect_click_position(event->x, event->y) == IN) {
-                               tmp_line.logic =  workplace->get_logic_item(CItem::gate_id);
-                               tmp_line.store = this;
+                               tmp_line.logic_id =  workplace->get_logic_item(CItem::gate_id)->get_id();
+                               tmp_line.store_id = ID;
                                workplace->lista_lineas_in.push_back(tmp_line);
                                workplace->queue_draw();        
                        } else if (detect_click_position(event->x, event->y) == OUT) {  
                                workplace->lista_lineas_in.push_back(tmp_line);
                                workplace->queue_draw();        
                        } else if (detect_click_position(event->x, event->y) == OUT) {  
-                               tmp_line.logic =  workplace->get_logic_item(CItem::gate_id);
-                               tmp_line.store = this;
+                               tmp_line.logic_id =  workplace->get_logic_item(CItem::gate_id)->get_id();
+                               tmp_line.store_id = ID;
                                workplace->lista_lineas_out.push_back(tmp_line);
                                workplace->queue_draw();
                        }
                                workplace->lista_lineas_out.push_back(tmp_line);
                                workplace->queue_draw();
                        }
@@ -91,7 +91,6 @@ bool Exclusa::on_button_press_event(GdkEventButton *event)
                if (estado) exclusa_pty_wnd->rd_btn_open->set_active(true);
                exclusa_pty_wnd->show();
        }
                if (estado) exclusa_pty_wnd->rd_btn_open->set_active(true);
                exclusa_pty_wnd->show();
        }
-       CItem::logic_connect =false;
        workplace->queue_draw();
        return true;
 }
        workplace->queue_draw();
        return true;
 }
index 668bed87962b190928ca3c95f96d46178b0fc7f4..463a91a8aaaa1c20889cd38dbf8afcc15c16367c 100644 (file)
@@ -26,10 +26,11 @@ bool Not::on_button_press_event(GdkEventButton *event)
 {
 
        if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 1)) {
 {
 
        if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 1)) {
-               CItem::logic_connect = true;
-               CItem::gate_id = ID;
+               if ( CItem::logic_connect ) {
+                       CItem::gate_id = ID;
+                       WorkPlace::pointed = ID;
+               }
                combo_entry->set_text(name);
                combo_entry->set_text(name);
-               WorkPlace::pointed = ID;
        }
        
        if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 2)){
        }
        
        if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 2)){
@@ -100,7 +101,7 @@ void Not::save(FILE *archivo)
        dato += c_img;
        dato += c_x;
        dato += c_y;
        dato += c_img;
        dato += c_x;
        dato += c_y;
-       for ( int i=0; i<=vec_connector.size()-1; i++) {
+       for ( int i=0; i<=vec_connector.size()-1&&!vec_connector.empty(); i++) {
                if ( vec_connector[i].type == IN ) {
                        dato += "\t\t<entrada>";
                        dato += vec_connector[i].name_dest + "</entrada>\n";
                if ( vec_connector[i].type == IN ) {
                        dato += "\t\t<entrada>";
                        dato += vec_connector[i].name_dest + "</entrada>\n";
@@ -119,9 +120,9 @@ bool Not::check_connection()
        t_logic_connector temp;
        std::list<t_line>::iterator i = workplace->lista_lineas_in.begin();
        while ( i != workplace->lista_lineas_in.end() ) {
        t_logic_connector temp;
        std::list<t_line>::iterator i = workplace->lista_lineas_in.begin();
        while ( i != workplace->lista_lineas_in.end() ) {
-               if ( (*i).logic->get_id() == ID ) {
+               if ( workplace->get_logic_item((*i).logic_id)->get_id() == ID ) {
                        temp.type = OUT;
                        temp.type = OUT;
-                       temp.name_dest = (*i).store->get_name();
+                       temp.name_dest = workplace->get_item((*i).store_id)->get_name();
                        vec_connector.push_back(temp);
                        cant_out++;
                }
                        vec_connector.push_back(temp);
                        cant_out++;
                }
@@ -130,9 +131,9 @@ bool Not::check_connection()
 
        i = workplace->lista_lineas_out.begin();
        while ( i != workplace->lista_lineas_out.end() ) {
 
        i = workplace->lista_lineas_out.begin();
        while ( i != workplace->lista_lineas_out.end() ) {
-               if ( (*i).logic->get_id() == ID ) {
+               if (workplace->get_logic_item((*i).logic_id)->get_id() == ID ) {
                        temp.type = IN;
                        temp.type = IN;
-                       temp.name_dest = (*i).store->get_name();
+                       temp.name_dest = workplace->get_item((*i).store_id)->get_name();
                        vec_connector.push_back(temp);
                        cant_in++;
                }
                        vec_connector.push_back(temp);
                        cant_in++;
                }
index 9668cace52175d23f8a2cc7cf26e3554ad5b19da..fbd2152f99f5aa51dc0bee3c1e52ec9c29cbed10 100644 (file)
@@ -25,10 +25,11 @@ Or::~Or()
 bool Or::on_button_press_event(GdkEventButton *event)
 {
        if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 1)) {
 bool Or::on_button_press_event(GdkEventButton *event)
 {
        if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 1)) {
-               CItem::logic_connect = true;
-               CItem::gate_id = ID;
+               if ( CItem::logic_connect ) {
+                       CItem::gate_id = ID;
+                       WorkPlace::pointed = ID;
+               }
                combo_entry->set_text(name);
                combo_entry->set_text(name);
-               WorkPlace::pointed = ID;
        }
        
        if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 2)){
        }
        
        if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 2)){
@@ -100,7 +101,7 @@ void Or::save(FILE *archivo)
        dato += c_img;
        dato += c_x;
        dato += c_y;
        dato += c_img;
        dato += c_x;
        dato += c_y;
-       for ( int i=0; i<=vec_connector.size()-1; i++) {
+       for ( int i=0; i<=vec_connector.size()-1&&!vec_connector.empty(); i++) {
                if ( vec_connector[i].type == IN ) {
                        dato += "\t\t<entrada>";
                        dato += vec_connector[i].name_dest + "</entrada>\n";
                if ( vec_connector[i].type == IN ) {
                        dato += "\t\t<entrada>";
                        dato += vec_connector[i].name_dest + "</entrada>\n";
@@ -119,9 +120,9 @@ bool Or::check_connection()
        t_logic_connector temp;
        std::list<t_line>::iterator i = workplace->lista_lineas_in.begin();
        while ( i != workplace->lista_lineas_in.end() ) {
        t_logic_connector temp;
        std::list<t_line>::iterator i = workplace->lista_lineas_in.begin();
        while ( i != workplace->lista_lineas_in.end() ) {
-               if ( (*i).logic->get_id() == ID ) {
+               if ( workplace->get_logic_item((*i).logic_id)->get_id() == ID ) {
                        temp.type = OUT;
                        temp.type = OUT;
-                       temp.name_dest = (*i).store->get_name();
+                       temp.name_dest = workplace->get_item((*i).store_id)->get_name();
                        vec_connector.push_back(temp);
                        cant_out++;
                }
                        vec_connector.push_back(temp);
                        cant_out++;
                }
@@ -130,9 +131,9 @@ bool Or::check_connection()
 
        i = workplace->lista_lineas_out.begin();
        while ( i != workplace->lista_lineas_out.end() ) {
 
        i = workplace->lista_lineas_out.begin();
        while ( i != workplace->lista_lineas_out.end() ) {
-               if ( (*i).logic->get_id() == ID ) {
+               if ( workplace->get_logic_item((*i).logic_id)->get_id() == ID ) {
                        temp.type = IN;
                        temp.type = IN;
-                       temp.name_dest = (*i).store->get_name();
+                       temp.name_dest = workplace->get_item((*i).store_id)->get_name();
                        vec_connector.push_back(temp);
                        cant_in++;
                }
                        vec_connector.push_back(temp);
                        cant_in++;
                }
index 9d2a95a0bc6e416cbbf747d4f53e50a229e26cfb..8fd4e0504fcff0ee2e12c62902482ba3898dc4a8 100644 (file)
@@ -42,15 +42,15 @@ bool Pump::on_button_press_event(GdkEventButton *event)
        if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 1)) {
                combo_entry->set_text(name);
                WorkPlace::pointed = ID;
        if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 1)) {
                combo_entry->set_text(name);
                WorkPlace::pointed = ID;
-               if (CItem::logic_connect) {
+               if (CItem::logic_connect && CItem::gate_id != -1) {
                        if ( detect_click_position(event->x, event->y) == IN) {
                        if ( detect_click_position(event->x, event->y) == IN) {
-                               tmp_line.logic =  workplace->get_logic_item(CItem::gate_id);
-                               tmp_line.store = this;
+                               tmp_line.logic_id =  workplace->get_logic_item(CItem::gate_id)->get_id();
+                               tmp_line.store_id = ID;
                                workplace->lista_lineas_in.push_back(tmp_line);
                                workplace->queue_draw();
                        } else if (detect_click_position(event->x, event->y) == OUT) {
                                workplace->lista_lineas_in.push_back(tmp_line);
                                workplace->queue_draw();
                        } else if (detect_click_position(event->x, event->y) == OUT) {
-                               tmp_line.logic =  workplace->get_logic_item(CItem::gate_id);
-                               tmp_line.store = this;
+                               tmp_line.logic_id =  workplace->get_logic_item(CItem::gate_id)->get_id();
+                               tmp_line.store_id = ID;
                                workplace->lista_lineas_out.push_back(tmp_line);
                                workplace->queue_draw();
                        }
                                workplace->lista_lineas_out.push_back(tmp_line);
                                workplace->queue_draw();
                        }
@@ -91,7 +91,6 @@ bool Pump::on_button_press_event(GdkEventButton *event)
                pump_pty_wnd->txt_pump_name->set_text( name );
                pump_pty_wnd->show();
        }               
                pump_pty_wnd->txt_pump_name->set_text( name );
                pump_pty_wnd->show();
        }               
-       CItem::logic_connect =false;
        workplace->queue_draw();
        return true;
 }
        workplace->queue_draw();
        return true;
 }
index 64ad9f55026c2160ddbec9dc352cfc3cdda6c682..1d93082b19ac460dd8f01e5aca73bde0d3d16f8a 100644 (file)
@@ -23,7 +23,6 @@ bool WorkPlace::on_expose_event(GdkEventExpose *event)
                        get_window()->draw_point (get_style()->get_black_gc(), x-1,y);
                }
                
                        get_window()->draw_point (get_style()->get_black_gc(), x-1,y);
                }
                
-       
        Glib::RefPtr<Gdk::GC> gc = get_style()->get_black_gc();
        Gdk::Color color;
        color.set_rgb(255,0,0);
        Glib::RefPtr<Gdk::GC> gc = get_style()->get_black_gc();
        Gdk::Color color;
        color.set_rgb(255,0,0);
@@ -33,31 +32,35 @@ bool WorkPlace::on_expose_event(GdkEventExpose *event)
        std::list<t_line>::iterator i = lista_lineas_in.begin();
        while ( i != lista_lineas_in.end() ) {
                t_line temp = *i;
        std::list<t_line>::iterator i = lista_lineas_in.begin();
        while ( i != lista_lineas_in.end() ) {
                t_line temp = *i;
-               temp.store->get_in_logic_connect_position(w,z);
-               temp.logic->get_out_logic_connect_position(a, b);
-               get_window()->draw_line (get_style()->get_black_gc(), a, b, w,z);
+               if ( get_item(temp.store_id) != NULL && get_logic_item(temp.logic_id) != NULL ) {
+                       get_item(temp.store_id)->get_in_logic_connect_position(w,z);
+                       get_logic_item(temp.logic_id)->get_out_logic_connect_position(a, b);
+                       get_window()->draw_line (get_style()->get_black_gc(), a, b, w,z);
+               }
                i++;
        }
        i = lista_lineas_out.begin();
        while ( i != lista_lineas_out.end() ) {
                t_line temp = *i;
                i++;
        }
        i = lista_lineas_out.begin();
        while ( i != lista_lineas_out.end() ) {
                t_line temp = *i;
-               temp.store->get_out_logic_connect_position(w,z);
-               temp.logic->get_in_logic_connect_position(a, b);
-               get_window()->draw_line (get_style()->get_black_gc(), a, b, w, z);
+               if ( get_item(temp.store_id) != NULL && get_logic_item(temp.logic_id) != NULL ) {
+                       get_item(temp.store_id)->get_out_logic_connect_position(w,z);
+                       get_logic_item(temp.logic_id)->get_in_logic_connect_position(a, b);
+                       get_window()->draw_line (get_style()->get_black_gc(), a, b, w, z);
+               }
                i++;
        }
                i++;
        }
-       
        return true;
 }
 
 void WorkPlace::delete_item(int _id)
 {
        return true;
 }
 
 void WorkPlace::delete_item(int _id)
 {
+       delete_line(_id);
        CItem::logic_connect = false;
        std::list<CItem*>::iterator i = listaItems->begin();
        while ( i != listaItems->end() ){
        CItem *temp = *i;
                if ( temp->get_id() == _id ){
        CItem::logic_connect = false;
        std::list<CItem*>::iterator i = listaItems->begin();
        while ( i != listaItems->end() ){
        CItem *temp = *i;
                if ( temp->get_id() == _id ){
-                       delete_line(_id);
+//                     delete_line(_id);
                        listaItems->erase(i);
                        delete temp;
                        break;
                        listaItems->erase(i);
                        delete temp;
                        break;
@@ -68,65 +71,80 @@ void WorkPlace::delete_item(int _id)
        while ( i != lista_logic_Items->end() ){
        CItem *temp = *i;
                if ( temp->get_id() == _id ){
        while ( i != lista_logic_Items->end() ){
        CItem *temp = *i;
                if ( temp->get_id() == _id ){
-                       delete_line(_id);
+//                     delete_line(_id);
                        lista_logic_Items->erase(i);
                        delete temp;
                        break;
                }
                i++;
        }
                        lista_logic_Items->erase(i);
                        delete temp;
                        break;
                }
                i++;
        }
-       
+       CItem::gate_id = -1;    
 }
 
 CItem* WorkPlace::get_logic_item(int _id)
 {
        std::list<CItem *>::iterator i = lista_logic_Items->begin();
        while ( i != lista_logic_Items->end() ){
 }
 
 CItem* WorkPlace::get_logic_item(int _id)
 {
        std::list<CItem *>::iterator i = lista_logic_Items->begin();
        while ( i != lista_logic_Items->end() ){
-               CItem *temp = *i;
-               if ( temp->get_id() == _id ) 
-                       return temp;
+               if ( (*i)->get_id() == _id ) 
+                       return *i;
+               i++;
+       }
+       return NULL;
+}
+
+CItem *WorkPlace::get_item(int _id)
+{
+       std::list<CItem *>::iterator i = listaItems->begin();
+       while ( i != listaItems->end() ){
+               if ( (*i)->get_id() == _id ) 
+                       return *i;
                i++;
        }
        return NULL;
 }
 
                i++;
        }
        return NULL;
 }
 
+       
 void WorkPlace::delete_line(int _id)
 {
        std::list<t_line>::iterator i = lista_lineas_in.begin();
        while ( i != lista_lineas_in.end() ){
 void WorkPlace::delete_line(int _id)
 {
        std::list<t_line>::iterator i = lista_lineas_in.begin();
        while ( i != lista_lineas_in.end() ){
-               if ( (*i).store->get_id() == _id ) {
-                       lista_lineas_in.erase(i);
-                       i = lista_lineas_in.begin();
-               }
+               if (get_item( (*i).store_id ) != NULL)
+                       if ( get_item( (*i).store_id )->get_id() == _id ) {
+                               lista_lineas_in.erase(i);
+                               i = lista_lineas_in.begin();
+                       }
                i++;
        }
 
        i = lista_lineas_in.begin();
        while ( i != lista_lineas_in.end() ){
                i++;
        }
 
        i = lista_lineas_in.begin();
        while ( i != lista_lineas_in.end() ){
-               if ( (*i).logic->get_id() == _id ) {
-                       lista_lineas_in.erase(i);
-                       i = lista_lineas_in.begin();
-               }
+               if ( get_logic_item((*i).logic_id) != NULL)
+                       if ( get_logic_item((*i).logic_id)->get_id() == _id) {
+                               lista_lineas_in.erase(i);
+                               i = lista_lineas_in.begin();
+                       }
                i++;
        }
 
                i++;
        }
 
-       i = lista_lineas_out.begin();
-       while ( i != lista_lineas_out.end() ){
-               if ( (*i).store->get_id() == _id ) {
-                       lista_lineas_out.erase(i);
-                       i = lista_lineas_out.begin();
-               }
-               i++;
-       }       
-       i = lista_lineas_out.begin();
-       while ( i != lista_lineas_out.end() ){
-               if ( (*i).logic->get_id() == _id ) {
-                       lista_lineas_out.erase(i);
-                       i = lista_lineas_out.begin();
-               }
-               i++;
+       std::list<t_line>::iterator j = lista_lineas_out.begin();
+       while ( j != lista_lineas_out.end() ){
+               if ( get_item((*j).store_id) != NULL )
+                       if ( get_item((*j).store_id)->get_id() == _id ) {
+                               lista_lineas_out.erase(j);
+                               j = lista_lineas_out.begin();
+                       }
+               j++;
        }       
 
        }       
 
+       j = lista_lineas_out.begin();
+       while ( j != lista_lineas_out.end() ){
+               if ( get_logic_item((*j).logic_id) != NULL )
+                       if ( get_logic_item((*j).logic_id)->get_id() == _id ) {
+                               lista_lineas_out.erase(j);
+                               j = lista_lineas_out.begin();
+                       }
+               j++;
+       }       
 }
 
 void WorkPlace::update_logic_position()
 }
 
 void WorkPlace::update_logic_position()