Fix screen problems by not relying on pass number in startCallback().

This commit is contained in:
Markus F.X.J. Oberhumer
2007-07-30 17:27:43 +02:00
parent b6f302dfc0
commit d556f58e34
2 changed files with 19 additions and 8 deletions
+18 -8
View File
@@ -69,6 +69,7 @@ struct UiPacker::State
#if defined(UI_USE_SCREEN) #if defined(UI_USE_SCREEN)
screen_t *screen; screen_t *screen;
int screen_init_done;
int b_cx, b_cy; int b_cx, b_cy;
int s_cx, s_cy; int s_cx, s_cy;
int s_fg, s_bg; int s_fg, s_bg;
@@ -237,6 +238,7 @@ void UiPacker::startCallback(unsigned u_len, unsigned step,
s->pass = pass; s->pass = pass;
s->total_passes = total_passes; s->total_passes = total_passes;
//printf("startCallback %d %d\n", s->pass, s->total_passes);
s->bar_len = 64; s->bar_len = 64;
s->pos = -2; s->pos = -2;
@@ -305,8 +307,9 @@ void UiPacker::startCallback(unsigned u_len, unsigned step,
#if defined(UI_USE_SCREEN) #if defined(UI_USE_SCREEN)
if (s->mode == M_CB_SCREEN) if (s->mode == M_CB_SCREEN)
{ {
if (pass <= 1) if (!s->screen_init_done)
{ {
s->screen_init_done = 1;
if (s->screen->hideCursor) if (s->screen->hideCursor)
s->cursor_shape = s->screen->hideCursor(s->screen); s->cursor_shape = s->screen->hideCursor(s->screen);
s->s_fg = s->screen->getFg(s->screen); s->s_fg = s->screen->getFg(s->screen);
@@ -343,12 +346,16 @@ void UiPacker::finalCallback(unsigned u_len, unsigned c_len)
**************************************************************************/ **************************************************************************/
void UiPacker::endCallback() void UiPacker::endCallback()
{
bool done = (s->total_passes <= 0 || s->pass >= s->total_passes);
endCallback(done);
}
void UiPacker::endCallback(bool done)
{ {
if (s->pass < 0) // no callback wanted if (s->pass < 0) // no callback wanted
return; return;
const bool done = (s->total_passes <= 0 || s->pass >= s->total_passes);
if (s->mode == M_CB_TERM) if (s->mode == M_CB_TERM)
{ {
if (done) if (done)
@@ -364,6 +371,8 @@ void UiPacker::endCallback()
if (done) if (done)
{ {
int cx, cy, sy; int cx, cy, sy;
assert(s->screen_init_done);
s->screen_init_done = 0;
assert(s->s_cx == 0 && s->b_cx == 0); assert(s->s_cx == 0 && s->b_cx == 0);
s->screen->getCursor(s->screen, &cx, &cy); s->screen->getCursor(s->screen, &cx, &cy);
sy = UPX_MAX(0, s->s_cy - s->scroll_up); sy = UPX_MAX(0, s->s_cy - s->scroll_up);
@@ -422,11 +431,6 @@ void UiPacker::doCallback(unsigned isize, unsigned osize)
s->next_update += s->step; s->next_update += s->step;
} }
#if 0
printf("%6d %6d %6d %6d\n", isize, osize, s->step, s->next_update);
return;
#endif
// compute progress position // compute progress position
int pos = -1; int pos = -1;
if (isize >= s->u_len) if (isize >= s->u_len)
@@ -436,6 +440,12 @@ void UiPacker::doCallback(unsigned isize, unsigned osize)
pos = get_ratio(s->u_len, isize) * s->bar_len / 1000000; pos = get_ratio(s->u_len, isize) * s->bar_len / 1000000;
assert(pos >= 0); assert(pos <= s->bar_len); assert(pos >= 0); assert(pos <= s->bar_len);
} }
#if 0
printf("%6d %6d %6d %6d %3d %3d\n", isize, osize, s->step, s->next_update, pos, s->pos);
return;
#endif
if (pos < s->pos) if (pos < s->pos)
return; return;
if (pos < 0 && pos == s->pos) if (pos < 0 && pos == s->pos)
+1
View File
@@ -72,6 +72,7 @@ public:
virtual void firstCallback(); virtual void firstCallback();
virtual void finalCallback(unsigned u_len, unsigned c_len); virtual void finalCallback(unsigned u_len, unsigned c_len);
virtual void endCallback(); virtual void endCallback();
virtual void endCallback(bool done);
virtual upx_callback_t *getCallback() { return &cb; } virtual upx_callback_t *getCallback() { return &cb; }
protected: protected:
static void __acc_cdecl progress_callback(upx_callback_p cb, unsigned, unsigned); static void __acc_cdecl progress_callback(upx_callback_p cb, unsigned, unsigned);