This project has moved and is read-only. For the latest updates, please go here.
1

Closed

Callback handler needs to return failure more than once

description

A "press ESC to abort" style handler like:
HRESULT __cdecl UVAtlasCallback( float fPercentDone  )
{
    static ULONGLONG s_lastTick = 0;

    ULONGLONG tick = GetTickCount64();

    if ( ( tick - s_lastTick ) > 1000 )
    {
        wprintf( L"%.2f%%   \r", fPercentDone * 100 );
        s_lastTick = tick;
    }

    if ( _kbhit() )
    {
        if ( _getch() == 27 )
        {
            wprintf(L"*** ABORT ***");
            return E_ABORT;
        }
    }

    return S_OK;
}
won't actually abort the UVAtlas functions like it should. Instead you have to do a stateful abort:
HRESULT __cdecl UVAtlasCallback( float fPercentDone  )
{
    static ULONGLONG s_lastTick = 0;
    static bool s_abort = false;

    ULONGLONG tick = GetTickCount64();

    if ( ( tick - s_lastTick ) > 1000 )
    {
        wprintf( L"%.2f%%   \r", fPercentDone * 100 );
        s_lastTick = tick;
    }

    if ( !s_abort && _kbhit() )
    {
        if ( _getch() == 27 )
        {
            wprintf(L"*** ABORT ***");
            s_abort = true;
        }
    }

    return s_abort ? E_ABORT : S_OK;
}
This is a bug in the callback handler that should be fixed.
Closed Apr 22, 2015 at 7:36 PM by walbourn
Added support to uvatlas command-line tool to check for ESC during the status callback and return E_ABORT if detected.

Updated uvatlas library to check for failed results from status callback in all cases to avoid need for 'stateful abort' workaround.

comments

walbourn wrote Apr 22, 2015 at 7:36 PM

Fixed with commit 9c2bc73d6f8d