Task #1901

Replace GUI_APP_MAIN_HOOK with something more polished

Added by Zbigniew Rebacz about 6 years ago. Updated about 6 years ago.

Status:RejectedStart date:08/11/2018
Priority:HighDue date:
Assignee:Miroslav Fidler% Done:

0%

Category:CtrlCoreSpent time:-
Target version:Release 2019.1

Description

GUI_APP_MAIN_HOOK is now part of public CtrlCore API and it looks bad and generates warning "GUI_APP_MAIN_HOOK" redefined when used as designed.

In my opinion GUI_APP_MAIN_HOOK problem should be solved in following way:

// Solution
std::function<bool()> AfterAppInitHandler = {};

#define GUI_APP_MAIN \
void GuiMainFn_(); \
\
int main(int argc, char *argv, const char *envptr) { \
    UPP::AppInit__(argc, (const char **)argv, envptr); \
    if(AfterAppInitHandler && AfterAppInitHandler()) \
        return UPP::GetExitCode(); \
        ...

// Usage:
INITBLOCK {
    AfterAppInitHandler = []() -> bool {
        // Do whatever you need here (handle command line etc.)...        

        return false;
    };
}

Clean and elegant solution compatible with c++11 and above that can be used in 3-rd party code with convenience.

History

#1 Updated by Zbigniew Rebacz about 6 years ago

  • Description updated (diff)

#2 Updated by Zbigniew Rebacz about 6 years ago

  • Description updated (diff)

#3 Updated by Miroslav Fidler about 6 years ago

  • Status changed from New to Rejected

Also available in: Atom PDF