mirror of
https://github.com/fltk/fltk.git
synced 2026-05-28 20:06:18 +08:00
Fix "fl_add_symbol() *always* increments symbnumb" (#1410).
Backported from master: 99648c047c
This commit is contained in:
committed by
Albrecht Schlosser
parent
49bc0a4fb1
commit
1869ba9455
+3
-2
@@ -68,10 +68,11 @@ static void fl_init_symbols(void);
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Adds a symbol to the system.
|
Adds a symbol to the system.
|
||||||
|
If a symbol with that name is already defined, its draw function is replaced by \p drawit.
|
||||||
\param[in] name name of symbol (without the "@")
|
\param[in] name name of symbol (without the "@")
|
||||||
\param[in] drawit function to draw symbol
|
\param[in] drawit function to draw symbol
|
||||||
\param[in] scalable set to 1 if \p drawit uses scalable vector drawing
|
\param[in] scalable set to 1 if \p drawit uses scalable vector drawing
|
||||||
\returns 1 on success, 0 on failure
|
\returns 1 on success, 0 if the maximum number of symbols has been reached.
|
||||||
*/
|
*/
|
||||||
int fl_add_symbol(const char *name, void (*drawit)(Fl_Color), int scalable)
|
int fl_add_symbol(const char *name, void (*drawit)(Fl_Color), int scalable)
|
||||||
{
|
{
|
||||||
@@ -79,11 +80,11 @@ int fl_add_symbol(const char *name, void (*drawit)(Fl_Color), int scalable)
|
|||||||
int pos;
|
int pos;
|
||||||
if (symbnumb > MAXSYMBOL / 2) return 0; // table is full
|
if (symbnumb > MAXSYMBOL / 2) return 0; // table is full
|
||||||
pos = find(name);
|
pos = find(name);
|
||||||
|
if (!symbols[pos].notempty) symbnumb++;
|
||||||
symbols[pos].name = name;
|
symbols[pos].name = name;
|
||||||
symbols[pos].drawit = drawit;
|
symbols[pos].drawit = drawit;
|
||||||
symbols[pos].notempty = 1;
|
symbols[pos].notempty = 1;
|
||||||
symbols[pos].scalable = scalable;
|
symbols[pos].scalable = scalable;
|
||||||
symbnumb++;
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user