コード例 #1
0
ファイル: app.cpp プロジェクト: CodeSmithyIDE/wxWidgets
void wxApp::OnEndSession(wxCloseEvent& WXUNUSED(event))
{
    // Windows will terminate the process soon after we return from
    // WM_ENDSESSION handler or when we delete our last window, so make sure we
    // at least execute our cleanup code before

    // prevent the window from being destroyed when the corresponding wxTLW is
    // destroyed: this will result in a leak of a HWND, of course, but who
    // cares when the process is being killed anyhow
    if ( !wxTopLevelWindows.empty() )
        wxTopLevelWindows[0]->SetHWND(0);

    // Destroy all the remaining TLWs before calling OnExit() to have the same
    // sequence of events in this case as in case of the normal shutdown,
    // otherwise we could have many problems due to wxApp being already
    // destroyed when window cleanup code (in close event handlers or dtor) is
    // executed.
    DeleteAllTLWs();

    const int rc = OnExit();

    wxEntryCleanup();

    // calling exit() instead of ExitProcess() or not doing anything at all and
    // being killed by Windows has the advantage of executing the dtors of
    // global objects
    exit(rc);
}
コード例 #2
0
ファイル: ServerTest.cpp プロジェクト: T-Rex/wxKinectHelper
int main(int & argc, char ** argv)
{
	int aargc = 0;
	char ** aargv = NULL;
	wxEntryStart(aargc, aargv);


	KinectDataSender * sender = new KinectDataSender(wxT("127.0.0.1"), 9500);
	if(sender->Create() != wxTHREAD_NO_ERROR)
	{
		wxDELETE(sender);
		return 1;
	}
	sender->Run();
	wxSleep(1);
	char * data = new char[10];
	sprintf(data, "12345");
	sender->SendKinectData(data, strlen(data), FRAME_COLOR);
	/*sprintf(data, "23456");
	sender->Send(data, strlen(data), FRAME_COLOR);
	sprintf(data, "34567");
	sender->Send(data, strlen(data), FRAME_COLOR);*/
	delete [] data;
	getchar();
	sender->Stop();
	sender->Delete();
	wxEntryCleanup();
	return 0;
}
コード例 #3
0
ファイル: init.cpp プロジェクト: gitrider/wxsj2
void wxUninitialize()
{
    wxCRIT_SECT_LOCKER(lockInit, gs_initData.csInit);

    if ( !--gs_initData.nInitCount )
    {
        wxEntryCleanup();
    }
}
コード例 #4
0
ファイル: client.cpp プロジェクト: heftyy/rpi-networking
int main(int argc, char** argv)
{
	wxApp::SetInstance(new gui_main());
	wxEntryStart(argc, argv);
	wxTheApp->OnInit();

	std::cout << "main test" << std::endl;

	wxTheApp->OnRun();
	wxTheApp->OnExit();
	wxEntryCleanup();

	/*
	std::cout << "main thread id = " << std::this_thread::get_id() << std::endl;

	try
	{
		actor_system as("client_system", 8558);
		std::string rpi_actor_ref = "[email protected]:8556";
		auto actor = std::shared_ptr<gpio_client_actor>(new gpio_client_actor(rpi_actor_ref, as, [](std::string msg)
		{
			std::cout << msg << std::endl;
		}));
		as.add_actor(actor);

		message response = actor->future(GPIO_CONNECT, 1000);
		if (response.type != GPIO_CONNECTED)
		{
			std::cout << "type is not GPIO_CONNECTED" << std::endl;
		}
		else if (response.type == GPIO_CONNECTED)
		{
			std::cout << "connect successed" << std::endl;
		}

		actor->tell(GPIO_REQUEST_PINS);

		_sleep(2000);
		//as.get_actor("test_actor");
	}
	catch (std::runtime_error)
	{
		std::cerr << "runtime error" << std::endl;
	}
	catch (std::exception& e)
	{
		std::cerr << e.what() << std::endl;
	}
	catch (...)
	{
		std::cout << "Got an exception!";
	}
	*/

	std::cout << "PROGRAM STOP" << std::endl;
	return 0;
}
コード例 #5
0
	void exitApp(int* result)
	{
		if ( wxTheApp )
			wxTheApp->OnExit();

		wxEntryCleanup();

		if (m_bExitCodeSet)
			*result = m_iExitCode;
	}
コード例 #6
0
ファイル: mfctest.cpp プロジェクト: nealey/vera
int CTheApp::ExitInstance()
{
#if !START_WITH_MFC_WINDOW
    delete m_pMainWnd;
#endif

    if ( wxTheApp )
        wxTheApp->OnExit();
    wxEntryCleanup();

    return CWinApp::ExitInstance();
}
コード例 #7
0
bool FileUniDialog (const std::string& sInitialDir, const std::string& sFilePattern, 
	const std::string& sTitle, std::string& sFilePath, bool open) {
	
	// store old working directory to restore it later
	char old_cwd[512];
	getcwd(old_cwd, 512);
	// and set cwd to the given one
	chdir(sInitialDir.c_str());
			
	// create minimal app and window
	wxApp *app = new wxApp();
	int args = 0;
	
	wxEntryStart(args,(wxChar **)0);

	wxWindow *mainWindow = new wxWindow();
	mainWindow->Show(FALSE);
	app->SetTopWindow(mainWindow);
	
	app->CallOnInit();
	
	// create and show dialog
	
	wxFileDialog* openFileDialog =
		new wxFileDialog( mainWindow, wxString::FromAscii(sTitle.c_str()), _(""), _(""), 
			wxString::FromAscii(sFilePattern.c_str()), 
			open ? (wxOPEN | wxFD_FILE_MUST_EXIST) : (wxSAVE | wxFD_OVERWRITE_PROMPT), 
			wxDefaultPosition);
 
 	bool ok = false;
 
	if ( openFileDialog->ShowModal() == wxID_OK ){
		sFilePath = openFileDialog->GetPath().ToAscii();
		ok = true;
	}

	wxEntryCleanup();
	
	delete mainWindow;

	// TODO manually delete app cause a segfault. unsure if this leads to a memory leak!
	//delete app;
	
	app = 0;
	mainWindow = 0;
	
	// restore working directory
	chdir(old_cwd);
	
	return ok;
}
コード例 #8
0
static bool destroyWxAppInstance(void) {
//   fprintf(logFile, "destroyWxAppInstance()\n");
   wxApp* wxApplication = static_cast<wxApp*>(wxApp::GetInstance());
   if (!wxInitializationSuccess) {
//      fprintf(logFile, "destroyWxAppInstance() - wxInitializationSuccess = false, No action)\n");
   }
   else {
      if (wxApplication != dummyApp) {
//         fprintf(logFile, "destroyWxAppInstance() - wxApplication != dummyApp, No action)\n");
      }
      else {
//         fprintf(logFile, "destroyWxAppInstance() - Doing wxEntryCleanup()\n");
         wxEntryCleanup();
//         fprintf(logFile, "destroyWxAppInstance() - Done wxEntryCleanup()\n");
      }
   }
//   fflush(logFile);
   return true;
}
コード例 #9
0
ファイル: flybot.cpp プロジェクト: jonny64/flybot
FLYBOT_API init(BotInit* apiInfo)
{
    if (NULL == apiInfo || apiInfo->apiVersion < 2)
        return false;
        
    apiInfo->botId = APP_NAME;
    apiInfo->botVersion = APP_VERSION;
    apiInfo->RecvMessage2 = OnRecvMessage2;
    
    FlybotAPI.Initialize(apiInfo);
    if (!wxTheApp || !wxTheApp->CallOnInit())
    {
        wxEntryCleanup();
        if (wxTheApp)
            wxTheApp->OnExit();
        return false;
    }
    
    return true;
}
コード例 #10
0
ファイル: app.cpp プロジェクト: vdm113/wxWidgets-ICC-patch
void wxApp::OnEndSession(wxCloseEvent& WXUNUSED(event))
{
    // Windows will terminate the process soon after we return from
    // WM_ENDSESSION handler or when we delete our last window, so make sure we
    // at least execute our cleanup code before

    // prevent the window from being destroyed when the corresponding wxTLW is
    // destroyed: this will result in a leak of a HWND, of course, but who
    // cares when the process is being killed anyhow
    if ( !wxTopLevelWindows.empty() )
        wxTopLevelWindows[0]->SetHWND(0);

    const int rc = OnExit();

    wxEntryCleanup();

    // calling exit() instead of ExitProcess() or not doing anything at all and
    // being killed by Windows has the advantage of executing the dtors of
    // global objects
    exit(rc);
}
コード例 #11
0
ファイル: flybot.cpp プロジェクト: jonny64/flybot
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID)
{
    int argc = 0;
    char **argv = NULL;
    switch (ul_reason_for_call)
    {
        case DLL_PROCESS_ATTACH:
            wxSetInstance((HINSTANCE)hModule);
            wxEntryStart(argc, argv);
            break;
        case DLL_THREAD_ATTACH:
            break;
        case DLL_THREAD_DETACH:
            break;
        case DLL_PROCESS_DETACH:
            if (wxTheApp)
                wxTheApp->OnExit();
            wxEntryCleanup();
            break;
    }
    return TRUE;
}
コード例 #12
0
void _wxPyCleanup()
{
    wxEntryCleanup();
}
コード例 #13
0
ファイル: pincode.cpp プロジェクト: ddt-tdd/eidonkey
void closePINCode(void) {
	wxEntryCleanup();
}
コード例 #14
0
Lugre::eLugreMessageBoxResult		LugreMessageBox				(Lugre::eLugreMessageBoxType iType,std::string sTitle,std::string sText) {
	wxApp *app = new wxApp();
	int args = 0;
	wxEntryStart(args,(wxChar **)0);
	//~ wxWindow *mainWindow = new wxWindow();
	//~ mainWindow->Show(FALSE);
	//~ app->SetTopWindow(mainWindow);
	app->CallOnInit();
	
	int style = wxOK;
	switch (iType) {
		case kLugreMessageBoxType_Ok			: style = wxOK; break;
		case kLugreMessageBoxType_OkCancel		: style = wxOK | wxCANCEL ; break;
		case kLugreMessageBoxType_YesNo			: style = wxYES_NO ; break;
		case kLugreMessageBoxType_YesNoCancel	: style = wxYES_NO | wxCANCEL ; break;
	}
	int res = wxMessageBox(wxString::FromAscii(sText.c_str()),wxString::FromAscii(sTitle.c_str()),style);
	
	wxEntryCleanup();
	//~ delete app; // segfaults ? weird, oh well, better a small memleak than a crash
	
	switch (res) {
		case wxYES:		return kLugreMessageBoxResult_Yes;
		case wxNO:		return kLugreMessageBoxResult_No;
		case wxCANCEL:	return kLugreMessageBoxResult_Cancel;
		case wxOK:		return kLugreMessageBoxResult_Ok;
	}
	// deactivated, still crashing
	return kLugreMessageBoxResult_BoxNotImplemented;

	#if 0
	// second attempt, but still problems if executed twice 
	int style = wxOK;
	switch (iType) {
		case kLugreMessageBoxType_Ok			: style = wxOK; break;
		case kLugreMessageBoxType_OkCancel		: style = wxOK | wxCANCEL ; break;
		case kLugreMessageBoxType_YesNo			: style = wxYES_NO ; break;
		case kLugreMessageBoxType_YesNoCancel	: style = wxYES_NO | wxCANCEL ; break;
	}
	
	int res = 0;
	if (0) {
		// note : http://wiki.wxwidgets.org/Wx_In_Non-Wx_Applications
		// In short you should use wxInitialize and wxUninitialize with a message loop in between
		// http://wiki.wxwidgets.org/Creating_A_DLL_Of_An_Application
		// http://docs.wxwidgets.org/2.6.3/wx_wxapp.html
		/*
		class wxDLLApp : public wxApp
		{
			int res;
			std::string sTitle;
			std::string sText;
			int style;
			wxDLLApp(int style,std::string sTitle,std::string sText) : style(style),sTitle(sTitle),sText(sText),res(0) {}
			bool OnInit() {
				res = wxMessageBox(wxString::FromAscii(sText.c_str()),wxString::FromAscii(sTitle.c_str()),style);
				ExitMainLoop();
			}
		};
		*/

		wxInitialize(); // (instead of wxEntry)
		//~ wxDLLApp* wxTheApp = new wxDLLApp(style,sTitle,sText);
		
		wxWindow *mainWindow = new wxWindow();
		mainWindow->Show(FALSE);
		wxTheApp->SetTopWindow(mainWindow);
		
		res = wxMessageBox(wxString::FromAscii(sText.c_str()),wxString::FromAscii(sTitle.c_str()),style);
		
		wxTheApp->OnExit();
		//~ wxApp::CleanUp();
		wxUninitialize();
		//~ res = wxTheApp->res;
		//~ delete wxTheApp;
	} else {
		wxApp *app = new wxApp();
		//~ wxApp::SetInstance(app);
		int args = 0;
		wxEntryStart(args,(wxChar **)0);
		
		//~ wxWindow *mainWindow = new wxWindow();
		//~ mainWindow->Show(FALSE);
		//~ app->SetTopWindow(mainWindow);
		app->CallOnInit();
		
		res = wxMessageBox(wxString::FromAscii(sText.c_str()),wxString::FromAscii(sTitle.c_str()),style);
		
		wxEntryCleanup();
		//~ delete app; // segfaults ? weird, oh well, better a small memleak than a crash
		// deactivated, still crashing
	}
	
	switch (res) {
		case wxYES:		return kLugreMessageBoxResult_Yes;
		case wxNO:		return kLugreMessageBoxResult_No;
		case wxCANCEL:	return kLugreMessageBoxResult_Cancel;
		case wxOK:		return kLugreMessageBoxResult_Ok;
	}
	
	return kLugreMessageBoxResult_BoxNotImplemented;
	#endif
}
コード例 #15
0
ファイル: init.cpp プロジェクト: gitrider/wxsj2
 ~wxCleanupOnExit() { wxEntryCleanup(); }
コード例 #16
0
ファイル: cmgui.cpp プロジェクト: A1kmm/libzinc
/*
Global functions
----------------
*/

#if defined (WX_USER_INTERFACE)

bool wxCmguiApp::OnInit()
{
	return (true);
}

wxAppTraits * wxCmguiApp::CreateTraits()
{
	return new wxGUIAppTraits;
}

void wxCmguiApp::OnIdle(wxIdleEvent& event)
{
	if (event_dispatcher)
	{
		if (Event_dispatcher_process_idle_event(event_dispatcher))
		{
			event.RequestMore();
		}
	}
}

void wxCmguiApp::SetEventDispatcher(Event_dispatcher *event_dispatcher_in)
{
	event_dispatcher = event_dispatcher_in;
}

BEGIN_EVENT_TABLE(wxCmguiApp, wxApp)
	EVT_IDLE(wxCmguiApp::OnIdle)
END_EVENT_TABLE()

IMPLEMENT_APP_NO_MAIN(wxCmguiApp)

#endif /*defined (WX_USER_INTERFACE)*/

#if !defined (WIN32_USER_INTERFACE) && !defined (_MSC_VER)
int main(int argc,const char *argv[])
#else /* !defined (WIN32_USER_INTERFACE)  && !defined (_MSC_VER)*/
int WINAPI WinMain(HINSTANCE current_instance,HINSTANCE previous_instance,
	LPSTR command_line,int initial_main_window_state)
	/* using WinMain as the entry point tells Windows that it is a gui and to use
		the graphics device interface functions for I/O */
	/*???DB.  WINDOWS a zero return code if WinMain does get into the message
		loop.  Other application interfaces may expect something else.  Should this
		failure code be #define'd ? */
	/*???DB. Win32 SDK says that don't have to call it WinMain */
#endif /* !defined (WIN32_USER_INTERFACE)  && !defined (_MSC_VER)*/
/*******************************************************************************
LAST MODIFIED : 7 January 2003

DESCRIPTION :
Main program for the CMISS Graphical User Interface
==============================================================================*/
{
	int return_code = 0;
#if defined (WIN32_USER_INTERFACE) || defined (_MSC_VER)
	int argc = 1, i;
	const char **argv;
	char *p, *q;
#endif /* defined (WIN32_USER_INTERFACE) */
	struct Cmiss_context_app *context = NULL;
	struct User_interface_module *UI_module = NULL;
	struct Cmiss_command_data *command_data;

#if !defined (WIN32_USER_INTERFACE) && !defined (_MSC_VER)
	ENTER(main);
#else /* !defined (WIN32_USER_INTERFACE)  && !defined (_MSC_VER)*/
	ENTER(WinMain);

	//_CrtSetBreakAlloc(28336);
	for (p = command_line; p != NULL && *p != 0;)
	{
		p = strchr(p, ' ');
		if (p != NULL)
			p++;
		argc++;
	}

	argv = (const char **)malloc(sizeof(*argv) * argc);

	argv[0] = "cmgui";

	for (i = 1, p = command_line; p != NULL && *p != 0;)
	{
		q = strchr(p, ' ');
		if (q != NULL)
			*q++ = 0;
		if (p != NULL)
			argv[i++] = p;
		p = q;
	}
#endif /* !defined (WIN32_USER_INTERFACE)  && !defined (_MSC_VER)*/

	/* display the version */
	display_message(INFORMATION_MESSAGE, "%s version %s\n%s\n"
		"Build information: %s %s\n", CMISS_NAME_STRING, CMISS_VERSION_STRING,
		CMISS_COPYRIGHT_STRING, CMISS_BUILD_STRING,
		CMISS_SVN_REVISION_STRING);

#if defined (CARBON_USER_INTERFACE) || (defined (WX_USER_INTERFACE) && defined (DARWIN))
	ProcessSerialNumber PSN;
	GetCurrentProcess(&PSN);
	TransformProcessType(&PSN,kProcessTransformToForegroundApplication);
#endif
	context = Cmiss_context_app_create("default");
#if defined (WX_USER_INTERFACE)
	int wx_entry_started = 0;
#endif
	if (context)
	{
#if defined (WX_USER_INTERFACE) || (!defined (WIN32_USER_INTERFACE) && !defined (_MSC_VER))
		UI_module = Cmiss_context_create_user_interface(context, argc, argv, NULL);
#else /* !defined (WIN32_USER_INTERFACE)  && !defined (_MSC_VER)*/
		UI_module = Cmiss_context_create_user_interface(context, argc, argv, current_instance,
			previous_instance, command_line, initial_main_window_state, NULL);
#endif /* !defined (WIN32_USER_INTERFACE)  && !defined (_MSC_VER)*/
		if (UI_module)
		{
#if defined (WX_USER_INTERFACE)
			if (UI_module->user_interface)
			{
				char **temp_argv = NULL, **cleanup_argv = NULL;
				int temp_argc = argc, cleanup_argc = argc;
				if (cleanup_argc > 0)
				{
					ALLOCATE(temp_argv, char *, cleanup_argc);
					ALLOCATE(cleanup_argv, char *, cleanup_argc);
					for (int i = 0; i < cleanup_argc; i++)
					{
						cleanup_argv[i] = temp_argv[i] = duplicate_string(argv[i]);
					}
				}
				if (wxEntryStart(temp_argc, temp_argv))
				{
					wx_entry_started = 1;
					wxXmlResource::Get()->InitAllHandlers();
					wxCmguiApp &app = wxGetApp();
					if (&app)
					{
						app.SetEventDispatcher(UI_module->event_dispatcher);
					}
					else
					{
						display_message(ERROR_MESSAGE,
							"initialiseWxApp.  wxCmguiApp not initialised.");
					}
				}
				else
				{
					display_message(ERROR_MESSAGE,
						"initialiseWxApp.  Invalid arguments.");
				}
				if (cleanup_argv)
				{
					for (int i = 0; i < cleanup_argc; i++)
					{
						DEALLOCATE(cleanup_argv[i]);
					}
					DEALLOCATE(temp_argv);
					DEALLOCATE(cleanup_argv);
				}
			}
#endif
			Cmiss_graphics_module_id graphics_module = NULL;
			if (NULL != (graphics_module = Cmiss_context_get_default_graphics_module(Cmiss_context_app_get_core_context(context))))
			{
				Cmiss_graphics_module_define_standard_materials(graphics_module);
				Cmiss_graphics_module_destroy(&graphics_module);
			}
			if (NULL != (command_data = Cmiss_context_get_default_command_interpreter(context)))
			{
				Cmiss_command_data_set_cmgui_string(command_data, CMISS_NAME_STRING,
					CMISS_VERSION_STRING, "CMISS_DATE_STRING", CMISS_COPYRIGHT_STRING, CMISS_BUILD_STRING,
					CMISS_SVN_REVISION_STRING);
				Cmiss_command_data_main_loop(command_data);
				Cmiss_command_data_destroy(&command_data);
				return_code = 0;
			}
			else
			{
				return_code = 1;
			}
			User_interface_module_destroy(&UI_module);
		}
		else
		{
			return_code = 1;
		}
		Cmiss_context_app_destroy(&context);
		Context_internal_cleanup();
#if defined (WX_USER_INTERFACE)
		if (wx_entry_started)
			wxEntryCleanup();
#endif
		/* FieldML does not cleanup the global varaibles xmlParser, xmlSchematypes and
		 * xmlCatalog at this moment, so we clean it up here instead*/
		xmlCatalogCleanup();
		xmlSchemaCleanupTypes();
		xmlCleanupParser();
	}
	else
	{
		return_code = 1;
	}
#if defined (WIN32_USER_INTERFACE) || defined (_MSC_VER)
	free(argv)
#endif
	LEAVE;

	return (return_code);
} /* main */
コード例 #17
0
ファイル: InitTest.cpp プロジェクト: AlessioFerri/TimeApp
 virtual void TearDown()
 {
 app->OnExit();
 wxEntryCleanup();
 }