[Date Prev][Date Next][Thread Prev][Thread Next][Thread Index]

Re: [XaraXtreme-dev] Open file, get standard colours



Attached is a patch that fixes the two places in Xara where assumptions
where made that a document always has at least one colour. These fixes
were simple. Instead of just calling a function, first a check is performed.

Also as part of this patch is a change to camdoc.cpp to remove the
EXCLUDE_FROM_XARALX from the code that determines if a filter needs a
default document or not. Maybe at one point this didn't work, but it has
been working for me. Without this, if you try to open an image, no
default document it loaded, and the only way to move the image around is
to resize it first.

Alex Bligh wrote:
> 
> 
> --On 28 June 2007 09:45 +0100 Gerry Iles <GerryI@xxxxxxxx> wrote:
> 
>> It is perfectly legal for a Xar file to not have any named colours in
>> and the program should not crash when this is the case.  Any problems
>> that occur when there are no colours are bugs and need to be fixed.
>>
>> The user may have deliberately created a default template document that
>> has no colours so the import should definitely not create a set of
>> default colours.  Loading of the default template to import into is the
>> only "correct" thing to do.
> 
> Yes; it wasn't the missing colours I was concerned with per-se, rather
> an improperly formed "default default" document when no template was
> loaded.
> 
> Alex
> 
Index: Kernel/colormgr.cpp
===================================================================
--- Kernel/colormgr.cpp	(revision 1776)
+++ Kernel/colormgr.cpp	(working copy)
@@ -1107,7 +1107,8 @@
 	}
 
 	// Sanity check. Should never ever ever be the case, ever.
-	ERROR3IF(UsefulColour->IsDeleted(),
+	if (UsefulColour != NULL)
+		ERROR3IF(UsefulColour->IsDeleted(),
 				"ColourManager::FindColourOfInterestToUser - Colour found is DELETED!");
 
 	// Fill in the return results
Index: wxOil/coldrop.cpp
===================================================================
--- wxOil/coldrop.cpp	(revision 1776)
+++ wxOil/coldrop.cpp	(working copy)
@@ -508,7 +508,8 @@
 	if (SelectIndex >= 0 && SelectIndex < (INT32)SpecialEntries.GetCount())
 		SelectedIndex = SelectIndex;
 
-	SetSelectedIndex(SelectedIndex);						// And set the appropriate selected item
+	if (Result)
+		SetSelectedIndex(SelectedIndex);						// And set the appropriate selected item
 
 	// Finally, enable the gadget, and trim its length down if necessary to fit the
 	// number of displayed items.
Index: wxOil/camdoc.cpp
===================================================================
--- wxOil/camdoc.cpp	(revision 1776)
+++ wxOil/camdoc.cpp	(working copy)
@@ -1075,7 +1085,7 @@
 		return TRUE;
 	}
 
-#ifndef EXCLUDE_FROM_XARALX
 PORTNOTE("other", "Assuming we actually do need a default document rather than asking the filter system");
 	// Find out the position of the filter selected by the user in the open dialog
 	INT32 SelectedPos = BaseFileDialog::SelectedFilter;
@@ -1124,9 +1134,9 @@
 	// If it is a filter family then we will have to work out what filter is actually
 	// required and hence ask that filter the qeustion.
 	if (!pFilter->IsDefaultDocRequired(pth.GetPath())) return TRUE;
-#else
-	return TRUE;
-#endif
 
 	//Graham 22/10/97: First set the template that this document is based on
 	SetTemplate(GetNextTemplateToUse());