|    123 // ============================================================================= | 
   123 // ============================================================================= | 
|    124 // ----------------------------------------------------------------------------- | 
   124 // ----------------------------------------------------------------------------- | 
|    125 LDDocument::~LDDocument() | 
   125 LDDocument::~LDDocument() | 
|    126 {	// Clear everything from the model | 
   126 {	// Clear everything from the model | 
|    127 	for (LDObject* obj : getObjects()) | 
   127 	for (LDObject* obj : getObjects()) | 
|    128 		delete obj; | 
   128 		obj->deleteSelf(); | 
|    129  | 
   129  | 
|    130 	// Clear the cache as well | 
   130 	// Clear the cache as well | 
|    131 	for (LDObject* obj : getCache()) | 
   131 	for (LDObject* obj : getCache()) | 
|    132 		delete obj; | 
   132 		obj->deleteSelf(); | 
|    133  | 
   133  | 
|    134 	delete m_History; | 
   134 	delete m_History; | 
|    135  | 
   135  | 
|    136 	// Remove this file from the list of files | 
   136 	// Remove this file from the list of files | 
|    137 	g_loadedFiles.removeOne (this); | 
   137 	g_loadedFiles.removeOne (this); | 
|    868 	m_Objects << obj; | 
   868 	m_Objects << obj; | 
|    869  | 
   869  | 
|    870 	if (obj->getType() == LDObject::Vertex) | 
   870 	if (obj->getType() == LDObject::Vertex) | 
|    871 		m_Vertices << obj; | 
   871 		m_Vertices << obj; | 
|    872  | 
   872  | 
|         | 
   873 #ifdef DEBUG | 
|         | 
   874 	if (!isImplicit()) | 
|         | 
   875 		dlog ("Added object #%1\n", obj->getID()); | 
|         | 
   876 #endif | 
|         | 
   877  | 
|    873 	obj->setFile (this); | 
   878 	obj->setFile (this); | 
|    874 	return getObjectCount() - 1; | 
   879 	return getObjectCount() - 1; | 
|    875 } | 
   880 } | 
|    876  | 
   881  | 
|    877 // ============================================================================= | 
   882 // ============================================================================= | 
|    878 // ----------------------------------------------------------------------------- | 
   883 // ----------------------------------------------------------------------------- | 
|    879 void LDDocument::addObjects (const QList<LDObject*> objs) | 
   884 void LDDocument::addObjects (const QList<LDObject*> objs) | 
|    880 {	for (LDObject * obj : objs) | 
   885 {	for (LDObject* obj : objs) | 
|    881 		if (obj) | 
   886 		if (obj) | 
|    882 			addObject (obj); | 
   887 			addObject (obj); | 
|    883 } | 
   888 } | 
|    884  | 
   889  | 
|    885 // ============================================================================= | 
   890 // ============================================================================= | 
|    892  | 
   897  | 
|    893 // ============================================================================= | 
   898 // ============================================================================= | 
|    894 // ----------------------------------------------------------------------------- | 
   899 // ----------------------------------------------------------------------------- | 
|    895 void LDDocument::forgetObject (LDObject* obj) | 
   900 void LDDocument::forgetObject (LDObject* obj) | 
|    896 {	int idx = obj->getIndex(); | 
   901 {	int idx = obj->getIndex(); | 
|         | 
   902 	assert (m_Objects[idx] == obj); | 
|         | 
   903 	dlog ("id: %1, type: %2, code: %3", obj->getID(), obj->getType(), obj->raw()); | 
|    897 	getHistory()->add (new DelHistory (idx, obj)); | 
   904 	getHistory()->add (new DelHistory (idx, obj)); | 
|    898 	m_Objects.removeAt (idx); | 
   905 	m_Objects.removeAt (idx); | 
|    899 	obj->setFile (null); | 
   906 	obj->setFile (null); | 
|    900 } | 
   907 } | 
|    901  | 
   908  | 
|   1013 	// stud.dat -> stud-logo.dat | 
  1020 	// stud.dat -> stud-logo.dat | 
|   1014 	// stud2.dat -> stud-logo2.dat | 
  1021 	// stud2.dat -> stud-logo2.dat | 
|   1015 	if (gl_logostuds && (flags & LDSubfile::RendererInline)) | 
  1022 	if (gl_logostuds && (flags & LDSubfile::RendererInline)) | 
|   1016 	{	if (getName() == "stud.dat" && g_logoedStud) | 
  1023 	{	if (getName() == "stud.dat" && g_logoedStud) | 
|   1017 			return g_logoedStud->inlineContents (flags); | 
  1024 			return g_logoedStud->inlineContents (flags); | 
|   1018  | 
        | 
|   1019 		elif (getName() == "stud2.dat" && g_logoedStud2) | 
  1025 		elif (getName() == "stud2.dat" && g_logoedStud2) | 
|   1020 		return g_logoedStud2->inlineContents (flags); | 
  1026 			return g_logoedStud2->inlineContents (flags); | 
|   1021 	} | 
  1027 	} | 
|   1022  | 
  1028  | 
|   1023 	QList<LDObject*> objs, objcache; | 
  1029 	QList<LDObject*> objs, objcache; | 
|   1024  | 
  1030  | 
|   1025 	bool deep = flags & LDSubfile::DeepInline, | 
  1031 	bool deep = flags & LDSubfile::DeepInline, | 
|   1026 		 doCache = flags & LDSubfile::CacheInline; | 
  1032 		 doCache = flags & LDSubfile::CacheInline; | 
|   1027  | 
  1033  | 
|   1028 	// If we have this cached, just clone that | 
  1034 	// If we have this cached, just create a copy of that | 
|   1029 	if (deep && getCache().size()) | 
  1035 	if (deep && getCache().size()) | 
|   1030 	{	for (LDObject* obj : getCache()) | 
  1036 	{	for (LDObject* obj : getCache()) | 
|   1031 			objs << obj->clone(); | 
  1037 			objs << obj->createCopy(); | 
|   1032 	} | 
  1038 	} | 
|   1033 	else | 
  1039 	else | 
|   1034 	{	if (!deep) | 
  1040 	{	if (!deep) | 
|   1035 			doCache = false; | 
  1041 			doCache = false; | 
|   1036  | 
  1042  | 
|   1047  | 
  1053  | 
|   1048 				// We only want to cache immediate subfiles, so shed the caching | 
  1054 				// We only want to cache immediate subfiles, so shed the caching | 
|   1049 				// flag when recursing deeper in hierarchy. | 
  1055 				// flag when recursing deeper in hierarchy. | 
|   1050 				QList<LDObject*> otherobjs = ref->inlineContents (flags & ~ (LDSubfile::CacheInline)); | 
  1056 				QList<LDObject*> otherobjs = ref->inlineContents (flags & ~ (LDSubfile::CacheInline)); | 
|   1051  | 
  1057  | 
|   1052 			for (LDObject * otherobj : otherobjs) | 
  1058 				for (LDObject* otherobj : otherobjs) | 
|   1053 				{	// Cache this object, if desired | 
  1059 				{	// Cache this object, if desired | 
|   1054 					if (doCache) | 
  1060 					if (doCache) | 
|   1055 						objcache << otherobj->clone(); | 
  1061 						objcache << otherobj->createCopy(); | 
|   1056  | 
  1062  | 
|   1057 					objs << otherobj; | 
  1063 					objs << otherobj; | 
|   1058 				} | 
  1064 				} | 
|   1059 			} | 
  1065 			} | 
|   1060 			else | 
  1066 			else | 
|   1061 			{	if (doCache) | 
  1067 			{	if (doCache) | 
|   1062 					objcache << obj->clone(); | 
  1068 					objcache << obj->createCopy(); | 
|   1063  | 
  1069  | 
|   1064 				objs << obj->clone(); | 
  1070 				objs << obj->createCopy(); | 
|   1065 			} | 
  1071 			} | 
|   1066 		} | 
  1072 		} | 
|   1067  | 
  1073  | 
|   1068 		if (doCache) | 
  1074 		if (doCache) | 
|   1069 			setCache (objcache); | 
  1075 			setCache (objcache); |