Commit f178d39b authored by Jehan's avatar Jehan

I will make further tests, but the segfault seems fixed. + better braces...

I will make further tests, but the segfault seems fixed. + better braces position in rxvtlib.h for vim
parent 96492c09
......@@ -2965,60 +2965,41 @@ rxvt_init_vts( rxvt_t *r, int page, int profile )
void
rxvt_destroy_termwin( rxvt_t *r, int page )
{
assert (page <= LTAB(r));
assert (PVTS(r, page)->tab_title);
assert (page <= LTAB(r));
assert (PVTS(r, page)->tab_title);
rxvt_free (PVTS(r, page)->tab_title);
SET_NULL(PVTS(r, page)->tab_title);
rxvt_free (PVTS(r, page)->tab_title);
SET_NULL(PVTS(r, page)->tab_title);
rxvt_free( PVTS(r, page)->title_format );
SET_NULL( PVTS(r, page)->title_format );
rxvt_free( PVTS(r, page)->title_format );
SET_NULL( PVTS(r, page)->title_format );
#ifdef XFT_SUPPORT
if (ISSET_OPTION(r, Opt_xft))
{
if (PVTS(r, page)->xftvt)
XftDrawDestroy (PVTS(r, page)->xftvt);
SET_NULL(PVTS(r, page)->xftvt);
}
if (ISSET_OPTION(r, Opt_xft))
{
if (PVTS(r, page)->xftvt)
XftDrawDestroy (PVTS(r, page)->xftvt);
SET_NULL(PVTS(r, page)->xftvt);
}
#endif
assert (IS_WIN(PVTS(r, page)->vt));
XDestroyWindow (r->Xdisplay, PVTS(r, page)->vt);
UNSET_WIN(PVTS(r, page)->vt);
assert (IS_WIN(PVTS(r, page)->vt));
XDestroyWindow (r->Xdisplay, PVTS(r, page)->vt);
UNSET_WIN(PVTS(r, page)->vt);
#ifdef BACKGROUND_IMAGE
if (IS_PIXMAP(PVTS(r, page)->pixmap))
{
XFreePixmap (r->Xdisplay, PVTS(r, page)->pixmap);
UNSET_PIXMAP(PVTS(r, page)->pixmap);
}
if (IS_PIXMAP(PVTS(r, page)->bg.pixmap))
{
XFreePixmap (r->Xdisplay, PVTS(r, page)->bg.pixmap);
UNSET_PIXMAP(PVTS(r, page)->bg.pixmap);
}
if (IS_PIXMAP(PVTS(r, page)->pixmap))
{
XFreePixmap (r->Xdisplay, PVTS(r, page)->pixmap);
UNSET_PIXMAP(PVTS(r, page)->pixmap);
}
if (IS_PIXMAP(PVTS(r, page)->bg.pixmap))
{
XFreePixmap (r->Xdisplay, PVTS(r, page)->bg.pixmap);
UNSET_PIXMAP(PVTS(r, page)->bg.pixmap);
}
#endif
rxvt_free (PVTS(r, page));
if (page < LTAB (r))
MEMMOVE (r->vts[page], r->vts[page + 1], (LTAB(r) - page) * sizeof (term_t*));
{
if (LTAB (r) == 0)
{
rxvt_free (r->vts);
SET_NULL (r->vts);
}
else
{
term_t** temp_vts = rxvt_realloc (r->vts, LTAB (r) * sizeof (term_t*));
if (temp_vts)
r->vts = temp_vts;
// if the realloc fails, this is not fatale as we can imagine it may be reallocated
// at the next change on tabs.
}
}
LTAB(r)--;
rxvt_free (PVTS(r, page));
}
......
......@@ -50,7 +50,8 @@ typedef uint32_t unicode_t;
struct rxvt_vars; /* defined later on */
struct rxvt_hidden; /* not defined here */
typedef struct {
typedef struct
{
int32_t row;
int32_t col;
} row_col_t;
......@@ -74,7 +75,8 @@ typedef unsigned char text_t;
* view_start: 0 <= view_start <= nscrolled
*/
typedef struct {
typedef struct
{
uint16_t fwidth, /* font width [pixels] */
fheight; /* font height [pixels] */
#ifdef XFT_SUPPORT
......@@ -206,7 +208,8 @@ typedef struct {
* Rows [TermWin.saveLines] ... [TermWin.saveLines + TermWin.nrow - 1]
* normal `unscrolled' screen region
*/
typedef struct {
typedef struct
{
text_t** text; /* _all_ the text */
int16_t* tlen; /* length of each text line */
rend_t** rend; /* rendition, uses RS_ flags */
......@@ -222,7 +225,8 @@ typedef struct {
} screen_t;
typedef struct {
typedef struct
{
unsigned char* text; /* selected text */
uint32_t len; /* length of selected text */
enum {
......@@ -240,7 +244,8 @@ typedef struct {
row_col_t end; /* one character past end point */
} selection_t;
typedef enum {
typedef enum
{
OLD_SELECT, OLD_WORD_SELECT, NEW_SELECT
} sstyle_t;
......@@ -416,7 +421,8 @@ typedef enum {
/* ------------------------------------------------------------------------- */
#ifdef HAVE_MENUBAR
typedef struct {
typedef struct
{
short state;
Window win;
GC gc;
......@@ -437,7 +443,8 @@ typedef struct {
#ifdef HAVE_SCROLLBARS
typedef struct {
typedef struct
{
char state; /* scrollbar state */
char init; /* scrollbar has been initialised */
short beg; /* slider sub-window begin height */
......@@ -501,7 +508,8 @@ typedef struct {
#endif /* HAVE_SCROLLBARS */
typedef struct {
typedef struct
{
char state; /* tabbar state */
short ltab; /* last tab */
......@@ -534,7 +542,8 @@ typedef struct {
#ifdef BACKGROUND_IMAGE
typedef struct {
typedef struct
{
short w, h, x, y;
Pixmap pixmap;
} bgPixmap_t;
......@@ -550,7 +559,8 @@ typedef struct {
# define XpmDepth (0)
# define XpmSize (0)
# define XpmReturnPixels (0)
typedef struct {
typedef struct
{
unsigned long valuemask;
Visual* visual;
Colormap colormap;
......@@ -563,7 +573,8 @@ typedef struct {
#endif /* BACKGROUND_IMAGE */
typedef enum {
typedef enum
{
TERMENV_XTERM = 0,
TERMENV_RXVT,
TERMENV_VT102,
......@@ -573,7 +584,8 @@ typedef enum {
} termenv_t;
struct term_t;
typedef struct {
typedef struct
{
/*
* Index to vts. If it's -1, then this term_t structure is not used.
* Otherwise, it is used by pointer vts[vts_idx]. This is to improve destroy
......@@ -787,14 +799,16 @@ typedef struct {
/*
* Action to take when a macro is called / menu item is selected.
*/
typedef struct {
typedef struct
{
unsigned short type; /* must not be changed; first element */
unsigned short len; /* strlen (str) */
unsigned char *str; /* action to take */
} action_t;
/* Values for macro_t.type. Must sync this with macroNames from macros.c */
enum {
enum
{
MacroFnDummy=0,
MacroFnEsc,
MacroFnStr,
......@@ -827,7 +841,8 @@ enum {
} macroFnNames;
typedef unsigned char macro_priority_t;
typedef struct {
typedef struct
{
KeySym keysym;
unsigned char modFlags; /* First 4 bits are the action order
number. Last four bits are the
......@@ -867,7 +882,8 @@ typedef struct _profile_t
} profile_t;
typedef struct rxvt_vars {
typedef struct rxvt_vars
{
/*
* These ``hidden'' items are not for public consumption and must not be
* accessed externally
......@@ -988,7 +1004,8 @@ typedef struct rxvt_vars {
} rxvt_t;
typedef enum {
typedef enum
{
HIDE_MENUBAR = 0,
SHOW_MENUBAR,
HIDE_TABBAR,
......
......@@ -1467,9 +1467,7 @@ rxvt_remove_page (rxvt_t* r, short page)
{
register int i;
rxvt_dbgmsg ((DBG_VERBOSE, DBG_TABBAR,"remove_page(%d)\n", page));
rxvt_dbgmsg ((DBG_VERBOSE, DBG_TABBAR,"rxvt_remove_page (r, %d)\n", page));
/* clean utmp/wtmp entry */
#ifdef UTMP_SUPPORT
......@@ -1496,20 +1494,41 @@ rxvt_remove_page (rxvt_t* r, short page)
/* destroy the virtual terminal window */
rxvt_destroy_termwin (r, page);
/* update total number of tabs */
//LTAB(r)--;
/* quit the last the terminal, exit the application */
if( LTAB(r) < 0 )
if (LTAB (r) == 0)
{
/* quit the last the terminal, exit the application */
rxvt_free (r->vts);
SET_NULL (r->vts);
rxvt_clean_exit (r);
}
/* update total number of tabs */
LTAB(r)--;
if (FVTAB(r) > page)
FVTAB(r)--;
if (LVTAB(r) > page)
LVTAB(r)--;
/* Reorganize the tabs array. */
/* update TermWin and tab_widths */
for (i = page; i <= LTAB(r); i++)
{
PVTS(r, i) = PVTS(r, i+1);
PVTS(r, i)->vts_idx = i;
refresh_tabbar_tab( r, i);
}
//if (page < LTAB (r))
//MEMMOVE (r->vts[page], r->vts[page + 1], (LTAB(r) - page) * sizeof (term_t*));
{
term_t** temp_vts = rxvt_realloc (r->vts, (LTAB (r) + 1) * sizeof (term_t*));
if (temp_vts)
r->vts = temp_vts;
// if the realloc failed, this is not fatale as we can imagine it may be reallocated
// at the next change on tabs.
}
/* update selection */
if (page == r->selection.vt)
rxvt_process_selectionclear (r, page);
......@@ -1521,9 +1540,11 @@ rxvt_remove_page (rxvt_t* r, short page)
* Must be careful here!!!
*/
/* update previous active tab */
if (PTAB(r) > page) PTAB(r)--;
if (PTAB(r) > page)
PTAB(r)--;
/* in case PTAB is invalid */
if (PTAB(r) > LTAB(r)) PTAB(r) = LTAB(r);
if (PTAB(r) > LTAB(r))
PTAB(r) = LTAB(r);
/* update active tab */
if( ATAB(r) == page )
......@@ -1532,10 +1553,13 @@ rxvt_remove_page (rxvt_t* r, short page)
ATAB(r) = PTAB(r);
/* Make the previous active tab the previous / next tab if possible. */
if( PTAB(r) > 0 ) PTAB(r)--;
else if (PTAB(r) < LTAB(r) ) PTAB(r)++;
if( PTAB(r) > 0 )
PTAB(r)--;
else if (PTAB(r) < LTAB(r) )
PTAB(r)++;
}
else if( ATAB(r) > page) ATAB(r)--;
else if( ATAB(r) > page)
ATAB(r)--;
/* always set mapped flag */
AVTS(r)->mapped = 1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment