コード例 #1
0
void GuiMetaDataEd::close(bool closeAllWindows)
{
	// find out if the user made any changes
	bool dirty = false;
	for(unsigned int i = 0; i < mEditors.size(); i++)
	{
		const std::string& key = mMetaDataDecl.at(i).key;
		if(mMetaData->get(key) != mEditors.at(i)->getValue())
		{
			dirty = true;
			break;
		}
	}

	std::function<void()> closeFunc;
	if(!closeAllWindows)
	{
		closeFunc = [this] { delete this; };
	}else{
		Window* window = mWindow;
		closeFunc = [window, this] {
			while(window->peekGui() != ViewController::get())
				delete window->peekGui();
		};
	}


	if(dirty)
	{
		// changes were made, ask if the user wants to save them
		mWindow->pushGui(new GuiMsgBox(mWindow,
			"SAVE CHANGES?",
			"YES", [this, closeFunc] { save(); closeFunc(); },
			"NO", closeFunc
		));
	}else{
		closeFunc();
	}
}
コード例 #2
0
 ~AVI()
 {
     if(avifp) closeFunc(avifp);
 }