Commit 54a541f2 authored by charras's avatar charras
Browse files

fixed crashes in eeschema, modedit and 3D display

parent 058bc4fd
Loading
Loading
Loading
Loading
+18 −28
Original line number Diff line number Diff line
@@ -491,17 +491,6 @@ void Pcb3D_GLCanvas::OnPaint( wxPaintEvent& event )
/*************************************************/
{
    wxPaintDC dc( this );

    // Set the OpenGL viewport according to the client size of this canvas.
    // This is done here rather than in a wxSizeEvent handler because our
    // OpenGL rendering context (and thus viewport setting) is used with
    // multiple canvases: If we updated the viewport in the wxSizeEvent
    // handler, changing the size of one canvas causes a viewport setting that
    // is wrong when next another canvas is repainted.
    const wxSize ClientSize = GetClientSize();

    glViewport( 0, 0, ClientSize.x, ClientSize.y );

    Redraw();
    event.Skip();
}
@@ -529,6 +518,24 @@ void Pcb3D_GLCanvas::InitGL()
        m_init = TRUE;
        g_Parm_3D_Visu.m_Zoom = 1.0;
        ZBottom = 1.0; ZTop = 10.0;

        glDisable( GL_CULL_FACE );      // show back faces

        glEnable( GL_DEPTH_TEST );      // Enable z-buferring

        glEnable( GL_LINE_SMOOTH );
        glEnable( GL_COLOR_MATERIAL );
        glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE );

        /* speedups */
        glEnable( GL_DITHER );
        glShadeModel( GL_SMOOTH );
        glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST );
        glHint( GL_POLYGON_SMOOTH_HINT, GL_FASTEST );

        /* blend */
        glEnable( GL_BLEND );
        glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
    }

    /* set viewing projection */
@@ -558,23 +565,6 @@ void Pcb3D_GLCanvas::InitGL()
    SetLights();


    glDisable( GL_CULL_FACE );      // show back faces

    glEnable( GL_DEPTH_TEST );      // Enable z-buferring

    glEnable( GL_LINE_SMOOTH );
    glEnable( GL_COLOR_MATERIAL );
    glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE );

    /* speedups */
    glEnable( GL_DITHER );
    glShadeModel( GL_SMOOTH );
    glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST );
    glHint( GL_POLYGON_SMOOTH_HINT, GL_FASTEST );

    /* blend */
    glEnable( GL_BLEND );
    glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
}


+11 −0
Original line number Diff line number Diff line
@@ -49,6 +49,17 @@ void Pcb3D_GLCanvas::Redraw( bool finish )
#else
    SetCurrent( );
#endif

    // Set the OpenGL viewport according to the client size of this canvas.
    // This is done here rather than in a wxSizeEvent handler because our
    // OpenGL rendering context (and thus viewport setting) is used with
    // multiple canvases: If we updated the viewport in the wxSizeEvent
    // handler, changing the size of one canvas causes a viewport setting that
    // is wrong when next another canvas is repainted.
    const wxSize ClientSize = GetClientSize();
    // *MUST* be called after  SetCurrent( ):
    glViewport( 0, 0, ClientSize.x, ClientSize.y );

    InitGL();

    glMatrixMode( GL_MODELVIEW );    /* position viewer */
+5 −9
Original line number Diff line number Diff line
@@ -77,11 +77,7 @@ WinEDA3D_DrawFrame::WinEDA3D_DrawFrame( WinEDA_BasePcbFrame* parent,
    ReCreateVToolbar();

    // Make a Pcb3D_GLCanvas

    m_Canvas = new Pcb3D_GLCanvas( this );

    /* init OpenGL once */
    m_Canvas->InitGL();
}


@@ -204,8 +200,8 @@ void WinEDA3D_DrawFrame::Process_Zoom( wxCommandEvent& event )
        return;
    }

    m_Canvas->DisplayStatus();
    m_Canvas->Refresh( FALSE );
    m_Canvas->DisplayStatus();
}


@@ -337,8 +333,8 @@ void WinEDA3D_DrawFrame::Process_Special_Functions( wxCommandEvent& event )
        return;
    }

    m_Canvas->DisplayStatus();
    m_Canvas->Refresh( true );
    m_Canvas->DisplayStatus();
}


@@ -348,9 +344,9 @@ void WinEDA3D_DrawFrame::NewDisplay()
{
    m_Canvas->ClearLists();
    m_Canvas->CreateDrawGL_List();
    m_Canvas->InitGL();
    m_Canvas->DisplayStatus();
//    m_Canvas->InitGL();
    m_Canvas->Refresh( true );
    m_Canvas->DisplayStatus();
}


+15 −3
Original line number Diff line number Diff line
@@ -208,11 +208,21 @@ void WinEDA_SchematicFrame::SaveCopyInUndoList( SCH_ITEM* aItem,
 *  saved in Undo List (for Undo or Redo commands, saved wires will be exchanged with current wire list
 */
{
    /* Does not save a null item.
     * but if aCommandType == UR_WIRE_IMAGE, we must save null item.
     * It happens for the first wire entered in schematic:
     * To undo this first command, the previous state is a NULL item,
     * and we accept this
     */
    if( aItem == NULL && (aCommandType != UR_WIRE_IMAGE) )     // Nothing to save
        return;

    SCH_ITEM*          CopyOfItem;
    PICKED_ITEMS_LIST* commandToUndo = new PICKED_ITEMS_LIST();
    commandToUndo->m_TransformPoint = aTransformPoint;

    ITEM_PICKER        itemWrapper( aItem, aCommandType );
    if( aItem )
        itemWrapper.m_PickedItemType = aItem->Type();

    switch( aCommandType )
@@ -270,6 +280,8 @@ void WinEDA_SchematicFrame::SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList,
    for( unsigned ii = 0; ii < aItemsList.GetCount(); ii++ )
    {
        SCH_ITEM*      item = (SCH_ITEM*) aItemsList.GetPickedItem( ii );
        if( item == NULL )
            continue;
        UndoRedoOpType command    = aItemsList.GetPickedItemStatus( ii );
        if( command == UR_UNSPECIFIED )
        {
@@ -332,7 +344,7 @@ void WinEDA_SchematicFrame::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bo
    {
        ITEM_PICKER itemWrapper = aList->GetItemWrapper( ii );
        item = (SCH_ITEM*) itemWrapper.m_PickedItem;
        wxASSERT( item  );
        if ( item )
            item->m_Flags = 0;
        SCH_ITEM*   image = (SCH_ITEM*) itemWrapper.m_Link;
        switch( itemWrapper.m_UndoRedoStatus )
+3 −0
Original line number Diff line number Diff line
@@ -313,6 +313,9 @@ void WinEDA_PcbFrame::SaveCopyInUndoList( BOARD_ITEM* aItem,
 *
 */
{
    if( aItem == NULL )     // Nothing to save
        return;

    BOARD_ITEM*        CopyOfItem;
    PICKED_ITEMS_LIST* commandToUndo = new PICKED_ITEMS_LIST();

Loading